curl command (Linux / bash / sh / zsh)
What it does
Transfer data to or from URLs using many network protocols. When people search for the curl command linux examples, they usually want curl's everyday flags, safe examples, and how it differs from related tools. Below you'll find syntax, options, and copyable examples for Bash/sh/zsh.
Transfer data to or from URLs using many network protocols.
Syntax
curl [OPTION]... URL...
Common options
| Flag / option | Meaning |
|---|---|
| -L | Follow HTTP redirects. |
| -o FILE | Write output to a named file. |
| -I | Fetch response headers only. |
| -X METHOD | Specify the request method. |
| -H HEADER | Add a request header. |
Practical examples
Download file
curl -L -o release.zip https://example.com/release.zip
Follows redirects and saves the response.
Check headers
curl -I https://example.com
Displays HTTP response headers.
Send JSON
curl -X POST -H 'Content-Type: application/json' -d '{"ok":true}' https://api.example.com/eventsPosts a small JSON document.
Linux ↔ Windows equivalent
Closest match: Invoke-WebRequest (Windows / PowerShell). Send HTTP and HTTPS requests and return response metadata and content.
Common mistakes
- Omitting `-L` when a download URL redirects.
- Putting secrets directly in shell history or verbose output.
Related commands
- wgetDownload web resources noninteractively, including recursive retrieval.
- pingTest IP reachability and measure round-trip response time.
- Invoke-WebRequestSend HTTP and HTTPS requests and return response metadata and content.
- ipconfigDisplay and manage Windows IP configuration and DNS client state.
- pingTest reachability and measure response time with ICMP echo requests.
- sshOpen a secure remote shell or run a command over SSH.
- netstatDisplay active connections, listening ports, routing data, and protocol statistics.
- scpCopy files securely between local and SSH-accessible hosts.
FAQ
What does curl do in Linux?
Transfer data to or from URLs using many network protocols.
How do I use curl from the terminal?
Start with `curl [OPTION]... URL...`, then choose only the options needed for the task.
What is a practical curl example?
Try `curl -L -o release.zip https://example.com/release.zip` — Follows redirects and saves the response.
Can I use curl in a shell script?
Yes. curl works in Bash, sh, and Zsh, but scripts should handle quoting, errors, and command output explicitly.
Browse the full Linux and Windows command reference to search more bash, CMD, PowerShell, Conda, and GitHub CLI commands.