curl

Curl Cheatsheet #

curl is a command-line tool used for transferring data with URLs. It supports various protocols and options.

Basic Commands #

Command/OptionExampleDescription
curl <url>curl http://example.comFetch the content of the URL
curl -O <url>curl -O http://example.com/file.txtDownload the file from the URL
curl -o <file> <url>curl -o myfile.txt http://example.com/file.txtSave the content to a file
curl -I <url>curl -I http://example.comFetch only the HTTP headers from the URL

Request Methods #

Command/OptionExampleDescription
curl -X GET <url>curl -X GET http://example.comPerform a GET request (default method)
curl -X POST <url>curl -X POST http://example.comPerform a POST request
curl -X PUT <url>curl -X PUT http://example.comPerform a PUT request
curl -X DELETE <url>curl -X DELETE http://example.comPerform a DELETE request

Data Sending #

Command/OptionExampleDescription
curl -d <data> <url>curl -d "name=value" http://example.comSend data in a POST request
curl -d @<file> <url>curl -d @data.json http://example.comSend data from a file in a POST request
curl -F <name=@file> <url>curl -F "file=@upload.txt" http://example.comUpload a file

Authentication #

Command/OptionExampleDescription
curl -u <user:password> <url>curl -u user:pass http://example.comUse HTTP basic authentication
curl -H "Authorization: Bearer <token>" <url>curl -H "Authorization: Bearer my_token" http://example.comUse Bearer token for authentication

Handling Output #

Command/OptionExampleDescription
curl -s <url>curl -s http://example.comSilent mode, no progress meter or error messages
curl -S <url>curl -S http://example.comShow errors in silent mode
curl -L <url>curl -L http://example.comFollow redirects

Additional Options #

Command/OptionExampleDescription
curl -v <url>curl -v http://example.comVerbose mode, show detailed information
curl --retry <num>curl --retry 3 http://example.comRetry request on failure

Troubleshooting #

Command/OptionExampleDescription
curl --trace <file> <url>curl --trace /tmp/trace.txt http://example.comTrace the request and response to a file

This cheatsheet provides fundamental curl commands and options for transferring data with URLs.

curl

Explore our comprehensive cheatsheets to enhance your knowledge and efficiency. Each cheatsheet provides detailed command options, examples, and descriptions to help you master various tools and technologies.