LLI Wiki — My Digital Knowledge Base

curl: useful commands (headers, download, certificate)

Headers, downloads, HTTPS target host override and certificate inspection with curl.

A few curl commands that come up often: inspecting headers and certificates, downloading files, and forcing the target host of an HTTPS request.

Show response headers

curl -s -D - -o /dev/null https://example.com
curl -I https://example.com

Download a file

curl "https://github.com/oracle-samples/db-sample-schemas/archive/refs/tags/v19.2.tar.gz" --output v19.2.tar.gz

# Follow redirects and use the remote file name
curl -LJO https://github.com/oracle-samples/db-sample-schemas/archive/refs/tags/v19.2.tar.gz

Target a specific host for an HTTPS request

Send a request to an IP address while presenting a given host name:

curl -k --header 'Host: sqlserver01' https://192.0.2.10
curl --connect-to 192.0.2.10:443 https://192.0.2.10

Inspect the TLS certificate

curl -vvI https://example.com

Resolve a "latest" download URL

Print the final URL after redirects:

curl -L --head -w '%{url_effective}' https://download.example.com/releases/latest.tar.bz2 2>/dev/null | tail -n1

Reference: 16 examples of the curl command (in French).

Mastodon LLIMastodon SocialFosstodon