Definition
curl transfers data from or to a URL using many protocols (HTTPS, HTTP, SFTP, LDAP, etc.). It is built on libcurl, so flags you learn in scripts match what languages embed for HTTP clients. Unlike a browser, curl does not execute JavaScript or render pages—it speaks the wire protocol directly.
Everyday HTTP patterns
| Goal | Example shape | Notes |
|---|---|---|
| Headers only | curl -I URL | HEAD request—great for cache/TTL checks |
| Follow redirects | curl -L URL | 301/302 chains to final body |
| POST JSON | curl -d '{"a":1}' -H 'Content-Type: application/json' URL | Quote carefully in shells |
| Custom Host/SNI | curl --resolve example.com:443:127.0.0.1 https://example.com | Local vhost testing |
| Timing trace | curl -w '%{time_connect} %{time_total}\n' -o /dev/null -s URL | DNS/TCP/TLS phases in variables |
TLS and trust
curl validates certificates against the system trust store. -k / --insecure disables verification—acceptable only for quick lab tests, never for production secrets. Use --cacert for private CAs.
curl vs wget
curl excels at verbs, headers, and APIs; wget historically shines at recursive static mirroring. Many tasks can be done with either—pick based on flags you remember and script clarity.
Related: Linux curl command explained, curl vs wget, How DNS works, X-Forwarded-For explained.