curl
Commandcurl
The curl
command is a versatile tool for transferring data to or from a server using various protocols, including HTTP, HTTPS, FTP, and more. It is commonly used for making API requests, downloading files, and testing web services.
curl [OPTIONS] [URL]
curl
curl
has a rich set of options that can be used to customize its behavior:
-V, --version
- Show version information and exit.-h, --help
- Display help information and exit.-X
- Specify a custom request method to use (e.g., GET, POST).-H
- Pass custom header(s) to the server.-o
- Write output to the specified file instead of stdout.-O
- Save the file with its original name from the server.-L, --location
- Follow redirects.-u
- Specify user and password for server authentication.-i
- Include HTTP response headers in the output.-s, --silent
- Silent mode (no output). Use with -S to show errors.--limit-rate
- Limit the download speed to rate
.curl
Commandcurl https://example.com
This command retrieves the content of the specified URL.
curl -O https://example.com/file.zip
This command downloads the file and saves it with its original name.
curl -d "name=John&age=30" -X POST https://example.com/api
This command sends data to the specified API using a POST request.
curl -L https://example.com/redirect
This command follows any redirects until it reaches the final URL.
curl -H "Authorization: Bearer token" https://example.com/api
This command includes a custom header in the request for authentication.
The output of the curl
command can include:
Option | Description |
---|---|
-V, --version |
Show version information and exit. |
-h, --help |
Display help information and exit. |
-d, --data |
Send specified data in a POST request. |
-X |
Specify a custom request method to use (e.g., GET, POST). |
-H |
Pass custom header(s) to the server. |
-o |
Write output to the specified file instead of stdout. |
-O |
Save the file with its original name from the server. |
-L, --location |
Follow redirects. |
-u |
Specify user and password for server authentication. |
-i |
Include HTTP response headers in the output. |
-s, --silent |
Silent mode (no output). Use with -S to show errors. |
--limit-rate |
Limit the download speed to rate . |