Catalog / Curl Comprehensive Cheatsheet
Curl Comprehensive Cheatsheet
A comprehensive cheat sheet for Curl, covering essential commands, options, and examples for effective command-line data transfer. Includes authentication, request types, data handling, SSL, and more.
Basic Usage & Options
Basic Syntax
Basic curl command structure. Options modify the behavior, and URL specifies the target. |
Simplest usage: retrieves the content of example.com and prints it to standard output. |
Output and Verbosity
|
Saves the output to the specified file instead of printing to stdout. Example: |
|
Enables verbose mode, showing detailed information about the request process (headers, connection details, etc.). Example: |
|
Silent mode. Doesn’t show progress meter or error messages. Useful for scripts. Example: |
|
When used with Example: |
Headers
|
Includes the HTTP headers in the output. Example: |
|
Performs a HEAD request, retrieving only the HTTP headers. Good for checking resource status. Example: |
|
Adds a custom header to the request. Example: |
|
Requests a compressed response using deflate or gzip. Example: |
Requests and Data Handling
Request Types
|
Specifies the HTTP request method (e.g., GET, POST, PUT, DELETE). Example: |
|
Follows HTTP redirects. Useful when a resource has moved. Example: |
|
Sends data with the HTTP GET method. Example: |
Data Transfer
|
Sends HTTP POST data, URL-encoded. Example: |
|
Sends data from a file as HTTP POST data. Example: |
|
Used for multipart/form-data, typically for file uploads. Example: |
Authentication
|
Provides username and password for HTTP authentication. Example: |
|
Use HTTP Basic Authentication (default when using Example: |
|
Use HTTP Digest Authentication Example: |
SSL/TLS Options
Certificate Verification
|
Specifies the CA certificate file for verifying the server’s certificate. Example: |
|
Specifies a directory containing CA certificates. Example: |
|
Skips SSL certificate verification. Use with caution! Example: |
Client Certificates
|
Specifies the client certificate file. Example: |
|
Specifies the client certificate type (DER, PEM, ENG). Example: |
–key |
Private key file name (SSL) Example: |
Other SSL Options
|
SSL ciphers to use Example: |
|
Force curl to use specified TLS version. Example: |
|
Allow security flaws present in older SSL/TLS versions Example: |
Advanced Usage
Cookies
|
Sends a cookie with the request. Example: |
|
Reads cookies from a file. Example: |
|
Stores received cookies in a file. Example: |
User Agent
Sets the User-Agent header. Example: |
Error Handling
|
Fail silently (no output at all) on HTTP errors. Example: |
|
Retry request specified number of times if transient problems occur Example: |
|
Maximum number of redirects allowed Example: |