Challenge - 5 Problems
Curl Command Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
What is the output of this curl command?
You run this command in a terminal to get the HTTP status code of a website:
What will this command output?
curl -o /dev/null -s -w "%{http_code}" https://example.comWhat will this command output?
Bash Scripting
curl -o /dev/null -s -w "%{http_code}" https://example.comAttempts:
2 left
💡 Hint
The flags -o /dev/null and -s hide the content and progress, -w "%{http_code}" prints the status code.
✗ Incorrect
The command fetches the URL but discards the body (-o /dev/null), runs silently (-s), and prints only the HTTP status code (-w "%{http_code}"). For a successful request, it outputs 200.
💻 Command Output
intermediate2:00remaining
What does this curl command output?
This command sends a POST request with JSON data:
What kind of output will you get?
curl -X POST -H "Content-Type: application/json" -d '{"name":"Alice"}' https://httpbin.org/postWhat kind of output will you get?
Bash Scripting
curl -X POST -H "Content-Type: application/json" -d '{"name":"Alice"}' https://httpbin.org/post
Attempts:
2 left
💡 Hint
httpbin.org/post echoes back the POST data in JSON format.
✗ Incorrect
The command sends JSON data to httpbin.org/post, which responds with JSON showing the data received and other request info.
🔧 Debug
advanced2:00remaining
Why does this curl command fail with a certificate error?
You run this command:
It fails with an SSL certificate error. Which option fixes this error by ignoring certificate validation?
curl https://self-signed.badssl.com/It fails with an SSL certificate error. Which option fixes this error by ignoring certificate validation?
Bash Scripting
curl https://self-signed.badssl.com/
Attempts:
2 left
💡 Hint
The option to ignore SSL certificate errors is --insecure or -k.
✗ Incorrect
The --insecure flag tells curl to skip SSL certificate verification, allowing connection to servers with self-signed or invalid certificates.
🚀 Application
advanced2:00remaining
How to save HTTP response headers to a file using curl?
You want to save only the HTTP response headers from a GET request to https://example.com into a file named headers.txt. Which command does this correctly?
Attempts:
2 left
💡 Hint
The -D option saves headers to a file; -o /dev/null discards the body.
✗ Incorrect
Using -D headers.txt saves the response headers to the file. The -o /dev/null discards the body so only headers are saved.
🧠 Conceptual
expert2:00remaining
What is the effect of this curl command in a script?
Consider this bash script snippet:
What will be stored in the variable
response=$(curl -s -w "%{http_code}" -o response.txt https://example.com)What will be stored in the variable
response after running this command?Bash Scripting
response=$(curl -s -w "%{http_code}" -o response.txt https://example.com)Attempts:
2 left
💡 Hint
The -w option outputs the status code to stdout, -o saves body to file, -s silences progress.
✗ Incorrect
The command saves the response body to response.txt (-o response.txt), suppresses progress (-s), and outputs only the HTTP status code (-w "%{http_code}"). This output is captured in the variable response.