Check a Website Availability from the Linux Command Line

You can easily test a a website availability from the Linux command line and get the status codes from the web-server using commands like TELNET or CURL.

Check a website availability with CURL

Execute the following command to check whether a web site is up, and what status message the web server is showing:

$ curl -Is http://www.shellhacks.com | head -1
HTTP/1.1 200 OK

Status code ‘200 OK’ means that the request has succeeded and a website is reachable.

Here is an another example that shows you how curl displays different status codes.

$ curl -Is http://shellhacks.com | head -n 1
HTTP/1.1 301 Moved Permanently

You’ll notice that if you visit: http://shellhacks.com you are redirected to http://www.shellhacks.com, because I prefer to have www in my site’s URL. I do this by implementing a 301 Redirect (Permanently moved) for any visitor who goes to http://shellhacks.com.

You can also check the availability of a particular page on the site:

$ curl -Is http://www.shellhacks.com/en/Bash-Colors | head -n 1
HTTP/1.1 200 OK

Read more: Status Code Definitions

Check a website availability with TELNET

You can also test website availability and get the response code using telnet command:

$ telnet www.shellhacks.com 80
Trying 91.206.200.119...
Connected to www.shellhacks.com.
Escape character is '^]'.
HEAD / HTTP/1.0
HOST: www.shellhacks.com
<PRESS ENTER>
<PRESS ENTER>

You will get the output as follows:

HTTP/1.1 200 OK
Server: nginx/1.1.10
Date: Sun, 26 May 2013 19:29:46 GMT
***

That also means that the website is OK.

0 (0)
Article Rating (No Votes)
Rate this article
Attachments
There are no attachments for this article.
Comments
There are no comments for this article. Be the first to post a comment.
Full Name
Email Address
Security Code Security Code
Related Articles RSS Feed
LVM: Extend SWAP size by adding a new Logical Volume
Viewed 1283 times since Sat, Jun 2, 2018
stunnel How To Set Up an SSL Tunnel Using Stunnel on Ubuntu
Viewed 579 times since Sun, Dec 6, 2020
How to do a Filesystem Resize (ext3/ext4) on Redhat running on VMware
Viewed 10117 times since Wed, Jul 25, 2018
How to mount software RAID1 member using mdadm
Viewed 2203 times since Wed, Oct 3, 2018
How to enable Proxy Settings for Yum Command on RHEL / CentOS Servers
Viewed 10248 times since Thu, Jul 19, 2018
Linux nslookup Command Examples for DNS Lookup
Viewed 7792 times since Sat, Sep 29, 2018
BIND for the Small LAN
Viewed 2637 times since Sun, May 20, 2018
Enabling or disabling a repository using Red Hat Subscription Management
Viewed 3615 times since Mon, Oct 29, 2018
stunnel: Authentication
Viewed 8400 times since Fri, Sep 28, 2018
HowTo: Find Out Hard Disk Specs / Details on Linux
Viewed 2101 times since Mon, Jan 28, 2019