Terminal Docs 1.0
background
Linux Terminal

Curl

Linux Terminal Util

curl Command Reference

The curl tool is used for transferring data to or from a server. It supports multiple protocols like HTTP, HTTPS, FTP, and more.

Syntax

curl [options] [URL...]

Common Options

  • -A, --user-agent: Specify the User-Agent string.

    curl -A "Mozilla/5.0" https://example.com
  • -b, --cookie: Send data as a cookie.

    curl -b "name=data" https://example.com
  • -c, --cookie-jar: Save cookies to a file.

    curl -c cookies.txt https://example.com
  • --compressed: Request a compressed response.

    curl --compressed https://example.com

Data and POST Requests

  • -d, --data: Send data with a POST request.

    curl -d "name=daniel&skill=lousy" https://example.com
  • -F, --form: Emulate form submission.

    curl -F "file=@/path/to/file" https://example.com/upload
  • -T, --upload-file: Upload a file.

    curl -T localfile.txt https://example.com/upload
  • -u, --user: Provide user credentials.

    curl -u username:password https://example.com
  • -X, --request: Specify custom HTTP methods.

    curl -X PUT https://example.com

HTTP Headers and Responses

  • -I, --head: Fetch only the headers of the response.

    curl -I https://example.com
  • -H, --header: Add custom HTTP headers.

    curl -H "User-Agent: MyAgent/1.0" https://example.com
  • -v, --verbose: Enable verbose output for debugging.

    curl --verbose https://example.com
  • --limit-rate: Limit the transfer rate.

    curl --limit-rate 1k https://example.com
  • -L, --location: Follow redirects.

    curl --location https://example.com

Miscellaneous

  • -k, --insecure: Allow insecure SSL connections.

    curl -k https://example.com
  • -o, --output: Save the output to a file.

    curl https://example.com -o example.html
  • -O, --remote-name: Save the output with the remote file name.

    curl -O https://example.com/file.txt
  • -s, --silent: Silent mode, no progress or error messages.

    curl --silent https://example.com
  • -w, --write-out: Output additional information.

    curl --write-out "%{http_code}" https://example.com
  • -x, --proxy: Use a proxy server.

    curl -x proxy.example.com:3128 https://example.com

Examples

  • Retrieve a Web Page

    curl https://example.com
  • Save Output to a File

    curl https://example.com -o example.html
  • Follow Redirects

    curl --location https://example.com
  • Upload a File

    curl -T /path/to/localfile.txt https://example.com/upload
  • Use a Proxy

    curl -x proxy.example.com:3128 https://example.com
  • Display Only HTTP Headers

    curl -I https://example.com

On this page