cURL Cheat Sheet

Curl is an awesome tool. I keep forgetting the switches though, so here’s a cheatsheet.

Simple GET request

curl -k "https://localhost/foo?bar=baz&abc=def"

JSON POST or PUT request

curl -k -H "Content-Type: application/json" -X POST -d '{"accountName":"test","value":"hello"}' https://localhost/foo
curl -X "PUT"
... for a PUT

POST a file

curl ... --data-binary @filename

Fake a /etc/hosts entry and a Host: header with curl

curl -vvv --resolve ''

Make a request with basic auth enabled

curl -vvv -u [email protected]:password


curl --user name:password

Set the Referer header

curl -e

Set the User Agent header

curl -A "Mozilla/4.73"


curl --user-agent "Mozilla".

Set Cookies

curl -b "name=Daniel"


curl --cookie "name=Daniel"

Time a request (connect time + time to first byte + total tile)

curl -o /dev/null -w "Connect: %{time_connect} TTFB: %{time_starttransfer} Total time: %{time_total} \n"

Downloading files from Github

curl -O


Brian has spent more than fifteen years as Unix enthusiast, specalising in systems administration and solutions architecture for SMB's to Fortune 100 companies. His career has focused on emerging and niche technologies to major advancements in the industry - most notibly cloud.