≡ Menu

How to get HTTP headers on Linux shell?

Question – How do I inspect the HTTP headers that a website sends on a Linux shell prompt?

There are two ways to get HTTP headers on a Linux shell prompt. One is called curl and the other command is called wget.

Using curl

Curl is a command line tool which can be used to download and inspect data over several protocols. To get the HTTP headers, use the -I argument to curl.

curl -I http://www.ewhathow.com

This will output the HTTP headers sent by ewhathow.com:

[root@server ~]# curl -I http://www.ewhathow.com
HTTP/1.1 200 OK
Date: Thu, 03 Oct 2013 07:07:30 GMT
Server: Apache
X-Powered-By: PHP/5.2.17
X-Pingback: http://www.ewhathow.com/xmlrpc.php
Content-Type: text/html; charset=UTF-8
[root@server ~]#

Using wget

HTTP headers can also be inspected using the command line tool called wget. The -S argument to wget will show the HTTP headers sent by the site:

wget -S http://www.ewhathow.com

This will output the HTTP headers as shown below:

[root@server ~]# wget -S http://www.ewhathow.com
--2013-10-03 11:09:17--  http://www.ewhathow.com/
Resolving www.ewhathow.com... 199.223.208.245
Connecting to www.ewhathow.com|199.223.208.245|:80... connected.
HTTP request sent, awaiting response...
  HTTP/1.0 200 OK
  Date: Thu, 03 Oct 2013 07:09:17 GMT
  Server: Apache
  X-Powered-By: PHP/5.2.17
  X-Pingback: http://www.ewhathow.com/xmlrpc.php
  Connection: close
  Content-Type: text/html; charset=UTF-8
Length: unspecified 
[root@server ~]#

{ 0 comments… add one }

Leave a Comment