2013-12-08 08:56:16 +00:00
|
|
|
# curl
|
|
|
|
|
2016-01-07 17:31:27 +00:00
|
|
|
> Transfers data from or to a server.
|
2024-07-27 15:13:47 +01:00
|
|
|
> Supports most protocols, including HTTP, HTTPS, FTP, SCP, etc.
|
2023-05-20 03:19:15 +01:00
|
|
|
> More information: <https://curl.se/docs/manpage.html>.
|
2013-12-08 08:56:16 +00:00
|
|
|
|
2024-07-27 15:13:47 +01:00
|
|
|
- Make an HTTP GET request and dump the contents in `stdout`:
|
A bunch of new pages:
common/: dig, gzip, rm, sort, zfs, zpool
linux/: apt-get, shutdown
osx/: airport, caffeinate, diskutil, networksetup open, pgrep, qlmanage, say, shutdown, sysctl, system_profiler
Edits to existing pages:
curl: Added simple download example
find: Added iname and size exmaples
grep: Edited -c description
ps: Added wide lines example
ssh: edited -D description, added simple port forwarding example
unzip: added list option
2014-02-10 20:36:05 +00:00
|
|
|
|
2024-07-27 15:13:47 +01:00
|
|
|
`curl {{https://example.com}}`
|
A bunch of new pages:
common/: dig, gzip, rm, sort, zfs, zpool
linux/: apt-get, shutdown
osx/: airport, caffeinate, diskutil, networksetup open, pgrep, qlmanage, say, shutdown, sysctl, system_profiler
Edits to existing pages:
curl: Added simple download example
find: Added iname and size exmaples
grep: Edited -c description
ps: Added wide lines example
ssh: edited -D description, added simple port forwarding example
unzip: added list option
2014-02-10 20:36:05 +00:00
|
|
|
|
2024-07-27 15:13:47 +01:00
|
|
|
- Make an HTTP GET request, fo[L]low any `3xx` redirects, and [D]ump the reply headers and contents to `stdout`:
|
2013-12-08 08:56:16 +00:00
|
|
|
|
2024-07-27 15:13:47 +01:00
|
|
|
`curl --location --dump-header - {{https://example.com}}`
|
2013-12-08 08:56:16 +00:00
|
|
|
|
2024-07-27 15:13:47 +01:00
|
|
|
- Download a file, saving the [O]utput under the filename indicated by the URL:
|
2013-12-08 08:56:16 +00:00
|
|
|
|
2024-07-27 15:13:47 +01:00
|
|
|
`curl --remote-name {{https://example.com/filename.zip}}`
|
2013-12-08 08:56:16 +00:00
|
|
|
|
2024-07-27 15:13:47 +01:00
|
|
|
- Send form-encoded [d]ata (POST request of type `application/x-www-form-urlencoded`). Use `--data @file_name` or `--data @'-'` to read from `stdin`:
|
2013-12-08 08:56:16 +00:00
|
|
|
|
2024-07-27 15:13:47 +01:00
|
|
|
`curl -X POST --data {{'name=bob'}} {{http://example.com/form}}`
|
2013-12-08 08:56:16 +00:00
|
|
|
|
2024-07-27 15:13:47 +01:00
|
|
|
- Send a request with an extra header, using a custom HTTP method and over a pro[x]y (such as BurpSuite), ignoring insecure self-signed certificates:
|
2013-12-08 08:56:16 +00:00
|
|
|
|
2024-07-27 15:13:47 +01:00
|
|
|
`curl -k --proxy {{http://127.0.0.1:8080}} --header {{'Authorization: Bearer token'}} --request {{GET|PUT|POST|DELETE|PATCH|...}} {{https://example.com}}`
|
2017-06-06 08:23:00 +01:00
|
|
|
|
2024-07-27 15:13:47 +01:00
|
|
|
- Send data in JSON format, specifying the appropriate Content-Type [H]eader:
|
2017-06-06 08:23:00 +01:00
|
|
|
|
2021-05-04 10:37:07 +01:00
|
|
|
`curl --data {{'{"name":"bob"}'}} --header {{'Content-Type: application/json'}} {{http://example.com/users/1234}}`
|
2016-01-12 19:24:22 +00:00
|
|
|
|
2017-04-19 19:25:38 +01:00
|
|
|
- Pass client certificate and key for a resource, skipping certificate validation:
|
2016-01-28 12:12:55 +00:00
|
|
|
|
2017-04-19 10:22:34 +01:00
|
|
|
`curl --cert {{client.pem}} --key {{key.pem}} --insecure {{https://example.com}}`
|
2024-07-27 15:13:47 +01:00
|
|
|
|
2024-07-27 22:17:12 +01:00
|
|
|
- Resolve a hostname to a custom IP address, with [v]erbose output (similar to editing the `/etc/hosts` file for custom DNS resolution):
|
2024-07-27 15:13:47 +01:00
|
|
|
|
2024-07-27 22:17:12 +01:00
|
|
|
`curl --verbose --resolve {{example.com}}:{{80}}:{{127.0.0.1}} {{http://example.com}}`
|