curl Command Examples in Linux¶
Introduction¶
These examples show practical ways to use curl on a Linux terminal. Each example is written so you can adapt it for administration or troubleshooting.
Example 1: Basic Usage¶
curl https://example.com
This is the simplest form of the command and is a good starting point before adding options.
Example 2: Common Admin Task¶
curl -I https://example.com
This example reflects a common task on RHEL, Rocky Linux, AlmaLinux, or similar systems.
Example 3: Useful Option¶
curl -o index.html https://example.com
This option helps narrow the result, change behavior, or handle a more realistic target.
Example 4: Real-World Scenario¶
curl -H "Accept: application/json" https://api.example.com/status
Use this pattern when the task moves beyond a single basic command.
Example 5: Verification¶
curl --version
Example output:
HTTP/2 200
content-type: text/html; charset=UTF-8
Common Mistakes¶
- Forgetting
-Lwhen the URL redirects. - Putting API tokens directly in shell history.
- Confusing response headers with response body output.
Quick Reference¶
curl https://example.com
curl -I https://example.com
curl -o index.html https://example.com
curl -H "Accept: application/json" https://api.example.com/status
curl --version
Related Guides¶
Summary¶
Good curl usage means choosing the right option, keeping the target clear, and verifying the result with output you can explain.