Skip to main content

Command referencecurl

curl command (Linux / bash / sh / zsh)

Linuxbashshzshnetworkbeginner

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 / optionMeaning
-LFollow HTTP redirects.
-o FILEWrite output to a named file.
-IFetch response headers only.
-X METHODSpecify the request method.
-H HEADERAdd 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/events

Posts 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.

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.