Skip to content

curl command

Make HTTP requests, call APIs and download files.

On this page

Syntax

curl [options] URL

Provided by the curl package. Run man curl for the full manual.

Common options

OptionWhat it does
-o FILESave to a file
-OSave with the remote file name
-LFollow redirects
-IHeaders only (HEAD request)
-X METHODRequest method, e.g. POST
-H "K: V"Add a header
-d DATASend data (POST)
-u user:passBasic authentication
-sSilent
-kSkip TLS certificate checks
-w FORMATPrint details, e.g. %{http_code}

Examples

  1. Fetch a page

    curl https://example.com
  2. Download a file

    curl -LO https://example.com/file.tar.gz
  3. Save with a new name

    curl -L -o app.zip https://example.com/download
  4. Show only the headers

    curl -I https://example.com
  5. Print just the status code

    curl -s -o /dev/null -w "%{http_code}\n" https://example.com
  6. POST JSON

    curl -X POST -H "Content-Type: application/json" -d '{"name":"demo"}' https://api.example.com/items
  7. Send a bearer token

    curl -H "Authorization: Bearer $TOKEN" https://api.example.com/me
  8. Upload a file (form)

    curl -F "file=@report.pdf" https://example.com/upload
  9. Resume a download

    curl -C - -O https://example.com/big.iso
  10. Pretty-print JSON

    curl -s https://api.github.com/repos/curl/curl | jq .

Tips

  • -k turns off certificate checks; use it only for testing.

curl guides

See all 14 guides that use curl →

← All Linux commands · Suggest a fix

Back to top