Skip to content

curl

150 commands

Transfers data with URLs over HTTP, FTP and many other protocols. Indispensable for testing APIs, headers and authentication.

  • HTTP
  • APIs
  • downloads

Install curl

sudo apt install curl

Basic Syntax5

curl https://example.com

Performs a standard GET request to the specified URL and prints the response to stdout.

curl -v https://example.com

Enables verbose mode to display request and response headers along with the handshake.

curl -I https://example.com

Fetches only the HTTP headers using a HEAD request.

curl -i https://example.com

Includes the HTTP response headers in the output before the response body.

curl --help

Displays the summary of curl options and usage categories.

Redirect Handling2

curl -L https://example.com

Follows HTTP 3xx redirects to the final destination URL.

curl -L --max-redirs 5 https://example.com

Follows redirects but limits the maximum number of hops to prevent infinite loops.

File Handling3

curl -O https://example.com/file.zip

Downloads the file and saves it using the remote filename.

curl -o output.html https://example.com

Saves the response output to a specifically named local file.

curl -C - -O https://example.com/large.iso

Resumes a specific file download from where it was interrupted.

Link

HTTP Methods5

curl -X POST https://api.local/resource

Sends an HTTP POST request with no data payload.

Link
curl -X DELETE https://api.local/resource/1

Sends an HTTP DELETE request to remove a resource.

Link
curl -X PUT -d "new data" https://api.local/resource/1

Sends an HTTP PUT request to update or create a resource with data.

Link
curl -X PATCH -d "update" https://api.local/resource/1

Sends an HTTP PATCH request to partially update a resource.

Link
curl -X OPTIONS https://api.local/resource

Sends an OPTIONS request to determine allowed methods on the server.

Link

Data Submission7

curl -d "param1=value1&param2=value2" https://example.com/login

Sends data as application/x-www-form-urlencoded in a POST request.

Link
curl --data-urlencode "name=John Doe" https://example.com/submit

Automatically URL-encodes the provided data field before sending.

Link
curl -H "Content-Type: application/json" -d '{"key":"value"}' https://api.local

Sends a raw JSON payload with the correct Content-Type header.

Link
curl --data-binary @filename.bin https://example.com/upload

Posts the exact binary content of a file without processing.

Link
curl -F "profile=@portrait.jpg" -F "name=User" https://example.com/upload

Submits a multipart/form-data request simulating a file upload form.

Link
curl -F "file=@local.txt;filename=remote.txt" https://example.com

Uploads a file via multipart form but renames it for the server.

Link
curl --json '{"key": "value"}' https://example.com

Shortcut (curl 7.82+) that sets Content-Type: application/json and Accept: application/json.

Link

Query Parameters1

curl -G -d "q=search" -d "page=1" https://example.com/api

Forces a GET request and appends data parameters to the URL query string.

Link

Headers5

curl -H "X-Custom-Header: value" https://example.com

Sends a custom HTTP header with the request.

Link
curl -A "Mozilla/5.0" https://example.com

Spoofs the User-Agent string to identify as a web browser.

Link
curl -e "https://google.com" https://example.com

Sets the Referer header to simulate navigation from another site.

Link
curl -H "Host: internal.local" https://192.168.1.10

Manually sets the Host header, useful for virtual host discovery.

Link
curl --header "X-Header:@file.txt" https://example.com

Reads the header value from a file (stripping newlines).

Link

Authentication7

curl -u username:password https://example.com

Performs Basic Authentication using a username and password.

Link
curl -u username https://example.com

Prompts the user interactively for the password for Basic Auth.

Link
curl -H "Authorization: Bearer <token>" https://api.local

Authenticates using a Bearer token in the header.

Link
curl --digest -u user:pass https://example.com

Uses Digest authentication instead of Basic.

Link
curl --ntlm -u user:pass https://example.com

Uses NTLM authentication, common in Windows environments.

Link
curl --negotiate -u : https://example.com

Uses GSS-API/SPNEGO Negotiate auth, often for Kerberos.

Link
curl --aws-sigv4 "aws:amz:region:service" --user "key:secret" https://api.amazonaws.com

Signs the request using AWS Signature Version 4.

Link

Cookies6

curl -c cookies.txt https://example.com/login

Saves received cookies from the server to a text file (cookie jar).

Link
curl -b cookies.txt https://example.com/dashboard

Sends cookies from a previously saved file to the server.

Link
curl -b "session_id=12345; user=admin" https://example.com

Manually passes cookie data in the request headers.

Link
curl -b cookies.txt -c cookies.txt https://example.com

Reads cookies from a file and writes updates back to the same file.

Link
curl -j -b cookies.txt https://example.com

Ignores session cookies (junk) from the file and reads only persistent ones.

Link
curl --cookie-jar - https://example.com

Writes the cookie jar to stdout after the operation.

Link

Proxy Usage6

curl -x http://proxy.local:8080 https://example.com

Routes the request through an HTTP proxy.

Link
curl -x socks5://proxy.local:1080 https://example.com

Routes the request through a SOCKS5 proxy.

Link
curl --proxy-user user:pass -x http://proxy.local:8080 https://example.com

Authenticates to the proxy server using Basic auth.

Link
curl --noproxy "*" https://internal.local

Bypasses configured proxies for specific hosts or all hosts.

Link
curl --proxytunnel -x http://proxy.local:8080 https://example.com

Uses the CONNECT method to tunnel SSL through an HTTP proxy.

Link
curl --proxy-insecure -x https://proxy.local https://example.com

Connects to an HTTPS proxy ignoring its certificate errors.

Link

SSL/TLS Security7

curl -k https://self-signed.local

Allows insecure connections to sites with invalid or self-signed SSL certificates.

Link
curl --cert client.pem --key key.pem https://secure.local

Authenticates using a client-side certificate and private key.

Link
curl --cacert ca-bundle.crt https://example.com

Verifies the server using a specific CA certificate bundle.

Link
curl --tlsv1.2 https://example.com

Forces the connection to use TLS version 1.2.

Link
curl --tlsv1.3 https://example.com

Forces the connection to use TLS version 1.3.

Link
curl --ciphers ECDHE-RSA-AES256-GCM-SHA384 https://example.com

Specifies exactly which cipher suite to use for the TLS handshake.

Link
curl --pinnedpubkey sha256//hashvalue https://example.com

Enforces SSL pinning by requiring the server key to match the provided hash.

Link

Performance Tuning3

curl --compressed https://example.com

Requests a compressed response (gzip/brotli) and decompresses it automatically.

Link
curl --no-keepalive https://example.com

Disables TCP keep-alive to force a new connection for the request.

Link
curl --limit-rate 100k https://example.com/largefile

Throttles the download speed to 100 kilobytes per second.

Link

Network Control7

curl --connect-timeout 5 https://example.com

Aborts if the connection to the server takes longer than 5 seconds.

Link
curl -m 20 https://example.com

Sets the maximum total time allowed for the entire operation to 20 seconds.

Link
curl --retry 3 --retry-delay 5 https://unstable.local

Retries the request up to 3 times with a 5-second delay on transient errors.

Link
curl --ipv4 https://example.com

Forces curl to resolve the name to an IPv4 address only.

Link
curl --ipv6 https://example.com

Forces curl to resolve the name to an IPv6 address only.

Link
curl --interface eth0 https://example.com

Binds the connection to a specific network interface.

Link
curl --resolve example.com:443:127.0.0.1 https://example.com

Manually forces the domain to resolve to a specific IP address for testing.

Link

Advanced HTTP3

curl --http2 https://example.com

Forces the client to attempt an HTTP/2 connection.

Link
curl --http2-prior-knowledge https://example.com

Issues HTTP/2 requests immediately without an HTTP/1.1 upgrade handshake.

Link
curl --http3 https://example.com

Forces the client to use HTTP/3 (QUIC) if supported by the build.

Link

Output Formatting7

curl -s https://example.com

Enables silent mode, suppressing the progress meter and error messages.

Link
curl -sS https://example.com

Enables silent mode but still outputs errors if they occur.

Link
curl -w "Status: %{http_code}\n" https://example.com

Writes a custom output format displaying the HTTP status code after completion.

Link
curl -w "Time: %{time_total}\n" -o /dev/null -s https://example.com

Measures total request time while discarding the response body.

Link
curl -w "DNS: %{time_namelookup} Connect: %{time_connect}\n" https://example.com

Provides a breakdown of DNS resolution and TCP connection timing.

Link
curl --dump-header headers.txt https://example.com

Saves the HTTP response headers into a separate file.

Link
curl -w "Type: %{content_type} Size: %{size_download}\n" https://example.com

Reports the content type and downloaded size after completion.

Link

Debugging6

curl --trace dump.txt https://example.com

Performs a full hex dump of incoming and outgoing data for debugging.

Link
curl --trace-ascii dump.txt https://example.com

Performs an ASCII dump of data traffic, easier to read than hex.

Link
curl --trace-time -v https://example.com

Prepends a timestamp to every line of verbose output.

Link
curl --libcurl code.c https://example.com

Generates C source code equivalent to the command line usage.

Link
curl --no-buffer https://example.com

Disables output buffering to display data as fast as it arrives.

Link
curl --fail-with-body https://example.com/api

Returns an error code on 400+ status but still saves the response body.

Link

Red Team / Security5

curl --path-as-is https://example.com/../../etc/passwd

Sends the path exactly as provided without dot-segment removal, for traversal testing.

Link
curl -X PUT --upload-file shell.php https://vuln.local/uploads/

Attempts to upload a file using the PUT method for vulnerability testing.

Link
curl --request-target "*" -X OPTIONS https://example.com

Sends an OPTIONS request to the server root to check global supported methods.

Link
curl -H "Host: malicious.com" -k https://target.com

Tests for Host Header Injection vulnerabilities.

Link
curl -H "User-Agent: () { :;}; echo CVE-2014-6271" https://example.com/cgi-bin/test

Sends a Shellshock payload in the User-Agent header.

Link

Blue Team / Validation4

curl -I -s https://example.com | grep -i "Content-Security-Policy"

Checks for the presence of the CSP security header.

Link
curl -I -s https://example.com | grep -i "Strict-Transport-Security"

Verifies that HSTS is enabled on the server.

Link
curl -s -o /dev/null -w "%{ssl_verify_result}\n" https://example.com

Checks the SSL verification result code (0 means success).

Link
curl --doh-url https://cloudflare-dns.com/dns-query https://example.com

Uses DNS-over-HTTPS (DoH) to bypass local DNS filters or logging.

Link

Protocol Fuzzing1

curl -v --header "Transfer-Encoding: chunked" --header "Content-Length: 10" https://example.com

Sends conflicting headers to test for Request Smuggling vulnerabilities.

Link

Other Protocols10

curl ftp://user:pass@ftp.example.com/file.txt

Downloads a file using the FTP protocol.

Link
curl -T local.txt ftp://user:pass@ftp.example.com/upload/

Uploads a file using FTP.

Link
curl telnet://example.com:23

Initiates a raw Telnet connection to the host.

Link
curl smtp://mail.example.com --mail-from me@example.com --mail-rcpt you@example.com --upload-file mail.txt

Sends an email using the SMTP protocol.

Link
curl ldap://ldap.example.com/dc=example,dc=com

Queries an LDAP server.

Link
curl pop3://pop.example.com -u user:password

Connects to a POP3 server to check mail.

Link
curl dict://dict.org/d:curl

Uses the DICT protocol to look up a word definition.

Link
curl tftp://192.168.1.1/file.txt

Downloads a file using TFTP (Trivial File Transfer Protocol).

Link
curl -u user:key sftp://example.com/file.txt

Downloads a file using SFTP (SSH File Transfer Protocol).

Link
curl gopher://example.com/

Connects to a server using the legacy Gopher protocol.

Link

Automation / CI3

curl -s -f https://example.com/health || exit 1

Fails silently (exit code 22) if the HTTP response is an error (4xx/5xx), suitable for pipelines.

Link
curl --create-dirs -o /tmp/folder/file.txt https://example.com

Automatically creates the local directory structure if it does not exist.

Link
curl -R -O https://example.com/file.zip

Sets the timestamp of the local file to match the remote file time.

Link

Advanced Config3

curl -K config.txt

Reads arguments and URLs from a configuration file.

Link
curl --url-query "name=val" https://example.com

Appends a query parameter to the URL, handling encoding automatically (newer curl versions).

Link
curl --haproxy-protocol https://example.com

Sends the HAProxy PROXY protocol header at the start of the connection.

Link

Header Manipulation2

curl -H "Accept:" https://example.com

Removes the default Accept header by sending it empty.

Link
curl -H "Expect:" -F "file=@large.iso" https://example.com

Disables the Expect: 100-continue header to reduce latency on large posts.

Link

DNS Control2

curl --dns-servers 1.1.1.1 https://example.com

Forces curl to use a specific DNS server for resolution.

Link
curl --dns-interface eth1 https://example.com

Forces DNS requests to go out through a specific network interface.

Link

Connection Control1

curl --keepalive-time 10 https://example.com

Sets the interval for TCP keep-alive probes to 10 seconds.

Link

Rate Limiting Simulation1

curl --limit-rate 500B https://example.com

Simulates extremely slow network conditions (500 bytes/sec).

Link

Security Testing2

curl -v --tls-max 1.1 https://example.com

Forces the connection to use no higher than TLS 1.1 to test legacy support.

Link
curl --crlfile revoked.crl https://example.com

Provides a Certificate Revocation List to check if the server cert is revoked.

Link

File Upload2

curl -T file.txt https://example.com/put

Short-hand for PUT file upload.

Link
curl -T "{file1,file2}.txt" https://example.com/

Uploads multiple files using globbing support.

Link

Globbing2

curl -O "https://example.com/img[001-100].jpg"

Downloads a sequence of files numbered 001 to 100.

Link
curl -O "https://example.com/{frontend,backend,db}.log"

Downloads multiple specific files using brace expansion.

Link

Unix Socket1

curl --unix-socket /var/run/docker.sock http://localhost/info

Connects to an HTTP server listening on a Unix Domain Socket (e.g., Docker).

Link

Output Handling1

curl --stderr output.log https://example.com

Redirects stderr (progress/errors) to a file instead of the terminal.

Link

Advanced Post2

curl -d @data.json -H "Content-Type: application/json" https://example.com

Reads POST data directly from a local file.

Link
curl --data-raw "@literal" https://example.com

Sends data containing an '@' symbol literally, without treating it as a filename.

Link

Advanced Auth1

curl --oauth2-bearer "TOKEN" https://example.com

Specific flag for providing an OAuth 2.0 bearer token.

Link

TLS 1.3 Features1

curl --tls13-ciphers TLS_AES_256_GCM_SHA384 https://example.com

Specifies cipher suites specifically for TLS 1.3 connections.

Link

Connection Debugging1

curl -v --trace-ids https://example.com

Adds connection and transfer IDs to verbose output for tracking multiplexed streams.

Link

URL Handling1

curl --location-trusted -u user:pass https://example.com

Follows redirects and forwards authentication credentials to the new host.

Link

Parallel Downloads1

curl -Z -O https://example.com/file1 -O https://example.com/file2

Performs parallel downloads of multiple URLs (requires libcurl with parallel support).

Link

Time Conditions2

curl -z "21 Dec 2023" https://example.com/file.txt

Downloads the file only if it was modified later than the specified date.

Link
curl -z -file.txt -O https://example.com/file.txt

Downloads the file only if the remote file is newer than the local file.

Link

Incident Response3

curl -s -I -X GET https://compromised.local

Safely retrieves headers from a potentially compromised host without executing content.

Link
curl --max-time 2 https://suspicious-ip.local

Probes a suspicious IP with a hard timeout to avoid hanging on tar-pits.

Link
curl -A "IncidentResponseBot/1.0" https://internal.log

Uses a specific User-Agent to tag traffic during an investigation.

Link

Tor / Anonymity1

curl --socks5-hostname localhost:9050 https://check.torproject.org

Routes traffic through Tor, resolving DNS remotely via the SOCKS proxy.

Link

HTTP/31

curl --alt-svc altsvc.cache https://example.com

Uses the Alt-Svc cache to upgrade connections to HTTP/3 or HTTP/2.

Link

Network1

curl --local-port 10000-11000 https://example.com

Forces the client to use a source port within a specific range.

Link

SSH1

curl -u user:pass scp://example.com/~/file.txt

Downloads a file via SCP (Secure Copy Protocol).

Link

TLS Security1

curl --tlsuser user --tlspassword pass https://example.com

Provides username/password for TLS-SRP authentication.

Link

Rate Limiting1

curl --speed-limit 1000 --speed-time 10 https://example.com

Aborts the download if speed drops below 1000 bytes/sec for 10 seconds.

Link

Output1

curl --progress-bar -O https://example.com/large.zip

Displays a simple progress bar instead of the standard meter.

Link

Red Team / Recon1

curl -I -X DELETE https://example.com/admin

Checks if the DELETE method is enabled on a sensitive endpoint without executing it completely.

Link

FTP2

curl --ftp-create-dirs -T local.txt ftp://example.com/new/path/

Uploads a file via FTP and creates the remote directory structure if missing.

Link
curl --ftp-ssl -u user:pass ftp://example.com

Forces FTPS (FTP over SSL) for secure transfer.

Link

Cleanup1

curl -K cleanup_config.txt

Runs a batch of delete/logout commands defined in a config file.

Link

API Testing1

curl -X POST -H "Content-Type: application/xml" -d "<xml>data</xml>" https://api.local

Submits an XML payload to a SOAP or XML-RPC endpoint.

Link

Red Team / Fuzzing1

curl -H "Range: bytes=0-18446744073709551615" https://example.com

Sends a malformed Range header to test for integer overflow vulnerabilities.

Link

Blue Team / Monitoring1

curl -s -w "%{remote_ip}" https://example.com

Outputs only the remote IP address of the server connected to.

Link

Proxy1

curl --proxy-header "Custom: Header" -x http://proxy.local https://example.com

Sends a custom header to the proxy server itself, not the destination.

Link

Advanced1

curl --engine list

Lists available OpenSSL crypto engines supported by the build.

Link