Show Menu
Cheatography

cURL cheat sheet Cheat Sheet by [deleted]

curl is the most powerful command in linux

Follow Redirects

-L

Cookies

-b cookiejar
Send Cookies using cookiejar
-c cookiejar
Store Cookies in cookiejar
-b 'n1=v1; n2=v2'
Send raw cookies using -b

Send Binary Data

--data­-binary
@<f­ile­nam­e>
Does not process the file before sending. -d sends it in ASCII.

Insecure SSL

-k / --insecure
By default all insecure requests fail. With -k, insecure requests do not fail.

Authen­tic­ation

-u
<us­ern­ame­:pa­ssw­ord>

Proxy

-x <pr­oxy>
Example :
-x 'http:­//p­rox­y:2080'

Compre­ssion

--comp­ression
Curl accepts compre­ssion encoding formats : gzip, deflate
 

POST Data

-d
<@filename>
-d
<da­ta>
Adding an @ reads the data from file.

HTTP Method

-X
<Me­tho­d>
Specify method to use : POST, HEAD, PUT, GET, DELETE

Output to file

-o <fi­len­ame>

Write to file

-O
Writes output to file instead of stdout

Max operation time

-m <se­con­ds>

Connect Timeout

--conn­ect­-ti­meout <se­con­ds>
Specify maximum time allowed to connect to remote server

Write Out

-w
<fo­rma­t>
Defines what to display on stdout after a completed and successful operation.
curl -s -w '%{rem­ote_ip} %{time­_total} %{http­_code} \n' -o /dev/null http:/­/an­kush.io
 

Send Header

-H <he­ade­r>

User Agent

-A 'User-­Age­nt-­Name'

Show Response Header

-i
Prints response headers along with response content.

HEAD Request

-I
Sends a HEAD request. Only response headers are printed.

Verbose output

-v
Useful to inspect headers
> means data sent by curl
< means data received by curl

Silent mode

-s
Does not output progress

Show Error

-S
When used with -s, this shows an error when it fails.

Exit Codes

6
Can't resolve host
7
Couldn't connect to host
28
Operation timeout
55
Failed to send data
56
Failed to receive data
               
 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          HTTP Status Codes Cheat Sheet
          rsync Cheat Sheet
          wget Cheat Sheet

          More Cheat Sheets by [deleted]