Challenge - 5 Problems
Curl Command Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate1:30remaining
What is the output of this curl command?
You run this command in a terminal:
What will be the output?
curl -s -o /dev/null -w "%{http_code}" https://httpbin.org/status/404What will be the output?
Linux CLI
curl -s -o /dev/null -w "%{http_code}" https://httpbin.org/status/404
Attempts:
2 left
💡 Hint
The -w option prints the HTTP status code. The URL returns a 404 status.
✗ Incorrect
The command suppresses output (-s), discards body (-o /dev/null), and prints only the HTTP status code (-w "%{http_code}"). The URL returns 404, so output is '404'.
💻 Command Output
intermediate1:30remaining
What does this curl command output?
Consider this command:
What kind of output will it produce?
curl -I https://example.com
What kind of output will it produce?
Linux CLI
curl -I https://example.com
Attempts:
2 left
💡 Hint
The -I option fetches headers only.
✗ Incorrect
The -I option tells curl to fetch only the HTTP headers, not the body content.
📝 Syntax
advanced2:00remaining
Which curl command correctly sends JSON data with POST?
You want to send JSON data '{"name":"Alice"}' to https://api.example.com/users using POST. Which command is correct?
Attempts:
2 left
💡 Hint
Use POST method, set content type to application/json, and provide data with -d.
✗ Incorrect
Option D correctly uses POST, sets the header to application/json, and sends the JSON data with -d. Option D has wrong content type. Option D uses GET which ignores data. Option D sends no data.
🔧 Debug
advanced2:00remaining
Why does this curl command fail to send data?
This command is run:
But the server reports only partial data received. Why?
curl -X POST https://api.example.com/data -d name=Bob&age=25
But the server reports only partial data received. Why?
Linux CLI
curl -X POST https://api.example.com/data -d name=Bob&age=25Attempts:
2 left
💡 Hint
Shell may split unquoted data into multiple arguments.
✗ Incorrect
Without quotes, the shell splits name=Bob&age=25 into multiple parts due to the & operator, so curl sends incomplete data. Quoting the data keeps it as one argument.
🚀 Application
expert2:30remaining
How to save only HTTP response headers to a file using curl?
You want to save only the HTTP headers from https://example.com to a file named headers.txt, without saving the body. Which command does this?
Attempts:
2 left
💡 Hint
Use -D to save headers, -o /dev/null to discard body.
✗ Incorrect
Option A saves headers to headers.txt (-D), discards body (-o /dev/null), and runs silently (-s). Option A saves headers to body file. Option A redirects headers to file but may include extra output. Option A saves full content.