curl (Command Line Tool) Reference
Kip Landergren
(Updated: )
My cheat sheet for curl covering common commands, documentation links, and frequently asked questions.
Contents
Commands
Note: when in doubt, read the man page—it has a wealth of information.
Make a request verbosely, ignoring insecure certificate warnings, to a custom IP address X.X.X.X
for a specific host and port pair:
curl --verbose \\
--insecure \\
--resolve 'example.com:443:X.X.X.X' \\
'https://example.com'
Write headers to a file:
curl --dump-header headers.txt \\
example.com
Write headers to a file and suppress final output and progress:
curl --silent \\
--dump-header headers.txt \\
--output /dev/null \\
example.com
Save a remote file locally as some-file.txt
, short-form:
curl -O example.com/some-file.txt
Save a remote file locally as some-file.txt
, long-form:
curl --remote-name example.com/some-file.txt
Specify headers:
curl -H 'X-Foo: A' -H 'X-Bar: B' example.com
POST with JSON data:
curl -H 'Content-Type: application/json' -X POST -d '{}' example.com
Options
--verbose | |
--location | follow redirects |
--output |
write output to file; use --output /dev/null to hide response contents |
Documentation
- GitHub repository
- Official Documentation Overview
FAQ
Why does curl sometimes appear to be stylized as “cURL” with capitalized “URL”?
“cURL”, with the capitalized “URL”, refers to the project, where curl
refers to the command line utility and libcurl
refers to the C Library.
More info available from the official FAQ question “What is cURL?”.