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
Linux - How to get network speed and statistic of ethernet adapter in Linux
Viewed 2342 times since Fri, Jun 8, 2018
Prosty skaner portów TCP w bash
Viewed 3470 times since Thu, May 24, 2018
How To Create a Linux Swap File
Viewed 2647 times since Fri, Jun 8, 2018
Linux RedHat How To Create An RPM Package
Viewed 3426 times since Sun, Jan 9, 2022
Setup SSL Tunnel Using Stunnel on Ubuntu
Viewed 2881 times since Fri, Sep 28, 2018
12 Tcpdump Commands – A Network Sniffer Tool
Viewed 8912 times since Fri, Jul 27, 2018
RHEL: Reinstalling Boot Loader on the Master Boot Record (MBR)
Viewed 3582 times since Sun, May 27, 2018
ZFS: Snapshots and clones on zfs filesystems
Viewed 3245 times since Sun, Jun 3, 2018
Creating SWAP partition using FDISK & FALLOCATE commands
Viewed 3694 times since Thu, Jan 16, 2020
RHEL7: Configure automatic updates.
Viewed 2027 times since Wed, Oct 17, 2018