curl

transfer data with URLs

TLDR

Download file
$ curl -O [https://example.com/file.zip]
Save to specific file
$ curl -o [filename] [https://example.com/file]
POST data
$ curl -X POST -d ["key=value"] [https://api.example.com]
Follow redirects
$ curl -L [https://example.com]
Send JSON
$ curl -H ["Content-Type: application/json"] -d ['{"key":"value"}'] [https://api.example.com]
Show headers
$ curl -I [https://example.com]

SYNOPSIS

curl [options] [URL...]

DESCRIPTION

curl is a command-line tool for transferring data with URLs. It supports HTTP, HTTPS, FTP, and many other protocols, making it essential for web development, API testing, and file transfers.The tool is ubiquitous in scripts, CI/CD pipelines, and system administration.

PARAMETERS

-O, --remote-name

Save with remote filename
-o, --output file
Save to specified file
-L, --location
Follow redirects
-X, --request method
HTTP method (GET, POST, PUT, DELETE)
-d, --data data
Send POST data
-H, --header header
Add custom header
-u, --user user:pass
Authentication
-I, --head
Fetch headers only
-v, --verbose
Verbose output
-s, --silent
Silent mode
-f, --fail
Fail silently on HTTP errors
-k, --insecure
Allow insecure SSL connections
-C, --continue-at offset
Resume a previous download (use `-` for auto)
--cookie data|file
Send cookies (inline string or file path)
--cookie-jar file
Write received cookies to file
--max-time seconds
Maximum time allowed for the transfer
--retry N
Retry failed transfers up to N times
-A, --user-agent string
Send User-Agent header
-e, --referer url
Send Referer header

CONFIGURATION

~/.curlrc

Default options loaded on every curl invocation (one option per line).
~/.netrc
Stores authentication credentials for remote hosts (used with --netrc).

INSTALL

sudo apt install curl
sudo dnf install curl
sudo pacman -S curl
sudo apk add curl
sudo zypper install curl
brew install curl
nix profile install nixpkgs#curl

CAVEATS

Silent failures by default (use -f to change). Large downloads show progress by default (use -s for scripts). Cookie files need management. SSL certificate issues require -k (insecure). Complex syntax for advanced features.

HISTORY

curl originated in 1996 as httpget (by Rafael Sagula, with Daniel Stenberg contributing), was renamed to urlget in 1997 when FTP support was added, and became curl with version 4.0 in March 1998. It is one of the most widely used command-line tools for data transfer.

SEE ALSO

wget(1), http(1)