curl usage


curl is a tool to transfer data from or to a server, using one of the supported protocols (DICT, FILE, FTP, FTPS, GOPHER, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMB, SMBS, SMTP, SMTPS, TELNET and TFTP).

The command is designed to work without user interaction.

curl offers a busload of useful tricks like proxy support, user authentication, FTP upload, HTTP post, SSL connections, cookies, file transfer resume, Metalink, and more. As you will see below, the number of features will make your head spin!

This is a simple summary about the usage of curl, for more details, just man curl in your terminal.

get raw content



use -o option to write to file instead of stdout.

curl -o <filename>

follow redirect

use -L option to follow the redirect.

curl -L

# will go to 

show response header

use -i option to show the response header with response. use -I option to only display the response header.

curl -i


use -v option to make the operation more talkative.

curl -v

use --trace <filename> or --trace-ascii <filename> to write a debug trace to file.

curl --trace log.txt
curl --trace-ascii log.txt

send form data

simply add in the url for get method.


use -X option to specify request command. use --data option for post method.

curl -X POST --data "data=xxx"

use --form option to specify httmp multipart data.

assuming the form was like below:

<form method="POST" enctype='multipart/form-data' action="upload.cgi">
  <input type=file name=upload>
  <input type=submit name=press value="OK">
curl --form upload=@localfilename --form press=OK [URL]


curl --referer

user agent

curl --user-agent "[User Agent]" [URL]

use -b or --cookie option to read cookies from file or string.

curl --cookie "name=xxx"

use -c option to write cookies to file after operation.

$ curl -c cookies
$ curl -b cookies

add header

curl --header "Content-Type:application/json"


curl --user name:password