network
curl
Transfers data to or from a server across many protocols including HTTP, HTTPS, FTP, and SCP. The Swiss Army knife of ad-hoc HTTP requests.
curl [OPTIONS] URL... Common flags
| Flag | Purpose |
|---|---|
| -X | HTTP method (GET, POST, PUT, DELETE, etc.) |
| -H | Add a request header |
| -d | Send a request body (URL-encoded by default) |
| -o | Write output to FILE |
| -O | Save with the remote filename |
| -L | Follow HTTP redirects |
| -I | Fetch headers only |
| -s | Silent mode (no progress meter); pair with -S to still show errors |
Examples
curl -L https://example.com GET a URL following redirects
curl -X POST -H 'Content-Type: application/json' -d '{"ok":true}' https://api.example.com POST a JSON payload
curl -sSL -o app.tgz https://example.com/app.tgz Quiet download with errors shown
curl -I https://example.com Inspect response headers only
Gotcha
By default curl does not follow redirects -- add -L, or you will see empty 301/302 responses.
Related commands
ssh
Opens an encrypted shell session to a remote host. Also runs single remote commands and can tunnel arbitrary TCP ports.
dig
Queries DNS servers for records and diagnostics. Preferred over nslookup for scripting and detailed troubleshooting.
rsync
Efficient file synchronizer that copies only the differences between source and destination. Works locally or over SSH.