Last Updated: May 1, 2025
curl — Essential Flags
curl https://api.example.comBasic GET request
curl -X POST url -d '{"key":"val"}'POST with JSON body
curl -H 'Content-Type: application/json' urlSet request header
curl -H 'Authorization: Bearer token' urlBearer token authentication
curl -u user:pass urlHTTP Basic Authentication
curl -v urlVerbose — show request and response headers
curl -I urlFetch response HEADERS only (HEAD request)
curl -L urlFollow redirects (Location header)
curl -o file.txt urlDownload to specific filename
curl -O urlDownload with remote filename
curl — Advanced Usage
curl -s -o /dev/null -w '%{http_code}' urlOutput status code only
curl -x proxy:8080 urlRoute through HTTP proxy
curl --data-urlencode 'q=hello world' urlURL-encode POST data
curl -F 'file=@photo.png' urlMultipart file upload
curl -k urlSkip SSL certificate verification (insecure!)
curl --connect-timeout 5 urlTimeout after 5 seconds connecting
curl -c cookies.txt urlSave cookies to file
curl -b cookies.txt urlSend saved cookies with request
curl -w '@curl-format.txt' urlCustom output formatting with write-out template
wget — Download Commands
wget urlBasic file download
wget -O file.zip urlSave to specific filename
wget -c urlResume interrupted download
wget -r -l 2 urlRecursive download (depth=2) — mirroring
wget -m urlMirror entire site (recursive + timestamping + infinite depth)
wget --limit-rate=500k urlThrottle download speed
wget --user=user --password=pass urlHTTP Basic Authentication
wget -i urls.txtDownload all URLs listed in a file
curl vs wget
| Feature | curl | wget |
|---|---|---|
| Primary purpose | Data transfer (APIs) | File downloading |
| Recursive download | No (use wget) | Yes (-r flag) |
| Built-in retry | --retry flag | Automatic retry |
| Protocols | HTTP, FTP, SMTP, IMAP, SCP, etc. | HTTP, HTTPS, FTP |
| Pipe output | Yes (stdout by default) | -O - to pipe to stdout |
| Cookie handling | -c / -b flags | --save-cookies / --load-cookies |
Pro Tip: Always use `curl -v` during development to see request/response headers. Use `curl -o /dev/null -s -w '%{http_code}'` for status-only checks in scripts.