*ARGS.TECH | BLOG | A Practical curl Cheatsheet for Developers & SysAdmins
Loading...
BLOG
A Practical curl Cheatsheet for Developers & SysAdmins
Terminal: ~

# Master the curl command with this cheatsheet. Learn to make GET/POST

# requests, send headers, download files, and test APIs from your command line.


# ----- A Practical `curl` Cheatsheet -----


# Simply fetch the content of a URL (GET request):

xinit@localhost:~$ curl https://example.com


# Show detailed info, including response headers (-i):

xinit@localhost:~$ curl -i https://example.com


# Show ONLY the response headers (-I or --head):

xinit@localhost:~$ curl -I https://example.com


# Follow redirects (-L for Location):

# Useful for shortened URLs or sites that redirect from http to https.

xinit@localhost:~$ curl -L https://t.co/shortlink


# ----- Advanced Requests -----


# Send a POST request with data (-X POST -d '...'):

xinit@localhost:~$ curl -X POST -d 'param1=value1&param2=value2' https://api.example.com/data


# Send a POST request with JSON data and set content type header (-H):

xinit@localhost:~$ curl -X POST -H "Content-Type: application/json" -d '{"key":"value"}' https://api.example.com/json


# Send a request with a custom header (e.g., Authorization):

xinit@localhost:~$ curl -H "Authorization: Bearer YOUR_API_TOKEN" https://api.example.com/secure


# Use basic authentication (user:password):

xinit@localhost:~$ curl -u myuser:mypassword https://api.example.com/login


# ----- Working with Data & Files -----


# Download a file and save it with its original name (-O):

xinit@localhost:~$ curl -O https://example.com/drivers/installer.iso


# Download a file and save it with a custom name (-o):

xinit@localhost:~$ curl -o my_installer.iso https://example.com/drivers/installer.iso


# Silently download a file (no progress meter) and show errors (-sS):

xinit@localhost:~$ curl -sS -O https://example.com/script.sh


# Test if an API endpoint is reachable and measure performance (-o /dev/null):

# Throws away the output, but shows connection times and stats.

xinit@localhost:~$ curl -s -o /dev/null -w "%{http_code} | %{time_total}s\n" https://api.example.com/health

www.args.tech
Top button
© *ARGS.TECH
2025
v 2.9.17