C.W.K.
Stream
Lesson 03 of 13 · published

curl Basics

~12 min · curl, http, headers, redirect

Level 0Pinger
0 XP0/101 lessons0/12 achievements
0/150 XP to next level150 XP to go0% complete

The Swiss Army knife of HTTP

curl talks HTTP, HTTPS, FTP, SCP, SFTP, and dozens of other protocols. Day-to-day, you use it for HTTP — fetch, follow redirects, set headers, send JSON. Master a small set of flags and curl handles 90% of API debugging from the terminal.

The flags worth memorizing

FlagPurpose
-vVerbose — show request and response headers
-IHEAD only — fetch headers, skip body
-LFollow 3xx redirects
-o fileWrite body to file
-OSave with the URL's filename
-sSilent (no progress bar)
-SShow errors even with -s
-w '%{http_code}'Print the status code (great for scripts)
--max-time NHard timeout in seconds

Code

Daily curl recipes·bash
# Just fetch a page
curl https://example.com

# Headers only
curl -I https://example.com

# Verbose — see everything
curl -v https://example.com

# Follow redirects, save to file with original name
curl -LO https://example.com/file.tar.gz

# Quiet health check that returns just the status code
curl -sS -o /dev/null -w '%{http_code}\n' https://example.com

# With a timeout
curl --max-time 5 -sS https://possibly-slow.example.com

External links

Exercise

Pick a URL you trust. Run curl -I https://... to see just the headers. Then curl -sS -o /dev/null -w 'http=%{http_code} time=%{time_total}s\n' https://... and note the metrics. This 4-flag pattern is your terminal-side uptime check.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.