CURL is a powerful command-line tool for making HTTP requests, testing APIs, uploading data, and more. This cheatsheet provides essential commands and use cases for ethical hackers, penetration testers, and developers. Whether you’re automating security tests or debugging APIs, this guide has you covered.

CURL Cheatsheet

The Ultimate Command Line Tool for Data Transfer

Basic CURL Requests

Basic GET Request
curl https://example.com
Fetch the contents of a URL using GET method.
Save Output to File
curl -o output.html https://example.com
Save the response to a file instead of stdout.
Follow Redirects
curl -L https://example.com
Follow HTTP 3xx redirects automatically.
Show Request Details
curl -v https://example.com
Verbose output showing request/response headers.
Ignore SSL Certificate
curl -k https://example.com
Connect to SSL site without verifying the certificate.
Limit Transfer Rate
curl --limit-rate 100K https://example.com
Limit download speed to 100 kilobytes per second.
Set User Agent
curl -A "Mozilla/5.0" https://example.com
Specify custom User-Agent string.
Show Only Headers
curl -I https://example.com
Fetch only the HTTP headers (HEAD request).

HTTP Methods

POST Request
curl -X POST https://example.com
Send a POST request instead of GET.
PUT Request
curl -X PUT https://example.com
Send a PUT request.
DELETE Request
curl -X DELETE https://example.com
Send a DELETE request.
PATCH Request
curl -X PATCH https://example.com
Send a PATCH request.
HEAD Request
curl -X HEAD https://example.com
Send a HEAD request (same as -I).
Custom Method
curl -X PURGE https://example.com
Send a custom HTTP method request.

Headers & Authentication

Add Header
curl -H "X-Custom-Header: value" https://example.com
Add custom header to the request.
Basic Authentication
curl -u username:password https://example.com
HTTP Basic authentication.
Bearer Token
curl -H "Authorization: Bearer token" https://example.com
Send Bearer token for authentication.
Multiple Headers
curl -H "Accept: application/json" -H "Content-Type: application/json" https://example.com
Add multiple headers to the request.
Digest Authentication
curl --digest -u username:password https://example.com
HTTP Digest authentication.
Referer Header
curl -e "https://referer.com" https://example.com
Set Referer header.
Cookie
curl -b "name=value" https://example.com
Send cookie with the request.
Save Cookies
curl -c cookies.txt https://example.com
Save cookies to file after request.
Load Cookies
curl -b cookies.txt https://example.com
Load cookies from file for request.

Data Transfer

POST Form Data
curl -d "name=value" https://example.com
Send form data (application/x-www-form-urlencoded).
Multiple Form Fields
curl -d "name1=value1" -d "name2=value2" https://example.com
Send multiple form fields.
POST JSON Data
curl -d '{"key":"value"}' -H "Content-Type: application/json" https://example.com
Send JSON data in POST request.
POST File Contents
curl -d @data.json https://example.com
Send contents of a file as POST data.
URL-encoded Data
curl --data-urlencode "name=value" https://example.com
Send URL-encoded form data.
Multipart Form Data
curl -F "name=value" -F "file=@filename.jpg" https://example.com
Send multipart form data (for file uploads).
Send Raw Data
curl --data-binary "@data.bin" https://example.com
Send raw binary data without processing.
GraphQL Query
curl -X POST -H "Content-Type: application/json" -d '{"query":"{user{name}}"}' https://example.com/graphql
Send GraphQL query.

File Transfer

Download File
curl -O https://example.com/file.zip
Download file and save with original name.
Download with Custom Name
curl -o customname.zip https://example.com/file.zip
Download file and save with custom name.
Resume Download
curl -C - -O https://example.com/file.zip
Resume a previous file transfer.
FTP Download
curl -u user:password -O ftp://example.com/file.zip
Download file from FTP server.
FTP Upload
curl -T localfile.zip -u user:password ftp://example.com/
Upload file to FTP server.
SFTP Download
curl -u user sftp://example.com/file.zip -o localfile.zip
Download file via SFTP.
Upload via SCP
curl -u user -T localfile scp://example.com/
Upload file via SCP.
Download Multiple Files
curl -O https://example.com/file1.zip -O https://example.com/file2.zip
Download multiple files at once.

Advanced Options

Use Proxy
curl -x http://proxy:port https://example.com
Use HTTP proxy for the request.
SOCKS Proxy
curl --socks5 host:port https://example.com
Use SOCKS5 proxy.
IPv6 Request
curl -6 https://example.com
Force IPv6 resolution.
IPv4 Request
curl -4 https://example.com
Force IPv4 resolution.
Connect Timeout
curl --connect-timeout 10 https://example.com
Set maximum time for connection (seconds).
Max Time
curl --max-time 30 https://example.com
Set maximum time for the entire operation.
Retry Failed Requests
curl --retry 3 https://example.com
Retry request up to 3 times if it fails.
Local Interface
curl --interface eth0 https://example.com
Use specific network interface.
Resolve IP
curl --resolve example.com:443:1.2.3.4 https://example.com
Provide custom IP for host resolution.
Use Specific SSL Version
curl --tlsv1.2 https://example.com
Force TLS 1.2 (other options: –tlsv1.0, –tlsv1.1, –tlsv1.3).
Client Certificate
curl --cert client.pem --key key.pem https://example.com
Use client certificate for authentication.
CA Certificate
curl --cacert ca-bundle.crt https://example.com
Use custom CA certificate bundle.

Output Options

Silent Mode
curl -s https://example.com
Silent mode (no progress or error messages).
Show Progress
curl -# -O https://example.com/file.zip
Show simple progress bar during download.
Show Only Errors
curl -S -s https://example.com
Silent but show errors.
Write Output to File
curl -o output.txt https://example.com
Write output to specified file.
Append to File
curl -a -o log.txt https://example.com
Append output to file instead of overwriting.
Show Headers Only
curl -i https://example.com
Include HTTP response headers in output.
Show Request Headers
curl -v https://example.com
Show both request and response headers.
Dump Headers to File
curl -D headers.txt https://example.com
Write received headers to file.

Common Use Cases

Check Website Status
curl -I https://example.com
Check HTTP headers and status code.
Test API Endpoint
curl -X POST -H "Content-Type: application/json" -d '{"param":"value"}' https://api.example.com/endpoint
Test a JSON API endpoint.
Download File with Auth
curl -u user:password -O https://example.com/file.zip
Download file with authentication.
Upload File to API
curl -F "file=@localfile.jpg" https://api.example.com/upload
Upload file to an API endpoint.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *