Overview
curl -I sends an HTTP HEAD request to retrieve only the server's response headers. It is primarily used to check the existence of web pages, redirection information, content types, and cache control directives. By not transferring the actual body data, it saves network traffic and reduces response time.
Key Features
- Sends HTTP HEAD requests
- Receives only response header information
- No content download (fast response)
- Useful for checking web server status and metadata
Key Options
Commonly used options with curl -I.
Request and Output Control
Generated command:
Try combining the commands.
Description:
`curl` Executes the command.
Combine the above options to virtually execute commands with AI.
Usage Examples
Various scenarios using the curl -I command.
Basic HTTP Header Check
curl -I https://www.example.com
Fetches only the HTTP response headers for the specified URL.
Check Headers While Following Redirects
curl -IL https://www.google.com
If a redirect occurs, this traces the redirect to the final destination and displays its headers.
Output Headers Silently
curl -Is https://www.github.com
Outputs only the response headers without any progress indicators.
Check Headers with Verbose Information
curl -Iv https://www.naver.com
Displays detailed information about the request and response, such as SSL handshake and HTTP request headers.
Filter Specific Headers
curl -Is https://www.example.com | grep 'Content-Type'
Can be combined with grep to extract specific header information.
Installation
curl is included by default in most Linux distributions, but if it's not, you can install it using the following commands.
Debian/Ubuntu
sudo apt update && sudo apt install curl
CentOS/RHEL/Fedora
sudo yum install curl
Arch Linux
sudo pacman -S curl
Tips & Precautions
Useful tips and points to note when using curl -I.
Checking HTTP Status Codes
The HTTP status code in the first line of the response headers allows you to quickly understand the current state of the web resource (e.g., 200 OK, 404 Not Found, 301 Moved Permanently).
- 200 OK: Request successful
- 3xx Redirection: Redirection required (use -L option)
- 4xx Client Error: Client-side error (e.g., 404 Not Found)
- 5xx Server Error: Server-side error
Analyzing Cache Control Headers
Headers like Cache-Control, Expires, and ETag help in understanding and debugging web resource caching strategies.
- Cache-Control: Caching policies such as max-age, no-cache, no-store
- Expires: Cache expiration time
- ETag: Resource version identifier
Security Considerations
Some web servers may include sensitive information in their response headers, such as server version or technology stack. This can provide potential attackers with system information, so be cautious about unnecessary information disclosure in public environments.