Transfers data from or to a server. Supports most protocols including HTTP, FTP, POP3.

# To download the contents of an URL to a file:
curl -o filename

# To download a file saving the output under the filename indicated by the URL:
curl -O

# To download a file, following [L]ocation redirects, and automatically [C]ontinuing (resuming) a previous file transfer:
curl -O -L -C -

# To send form-encoded data (POST request of type application/x-www-form-urlencoded):
curl -d 'name=bob'

# To send a request with an extra header using a custom HTTP method:
curl -H 'X-My-Header: 123' -X PUT

# To send data in JSON format, specifying the appropriate content-type header:
curl -d '{"name":"bob"}' -H 'Content-Type: application/json'

# To pass a user name and password for server authentication and show headers info only:
curl -u myusername:mypassword -I

# To pass client certificate and key for a secure resource:
curl -v -key key.pem -cacert ca.pem -cert client.pem -k

# -----------------------------------------------------------------------------

# To set request headers (-v verbose):
curl -v -H "Accept: application/json"

# To sequentially download numbered resources (01-24), and set the naming pattern:
curl[01-24].pdf -o "chapter-#1.pdf"

# To download remote resoureces using braces {..} to specify alternatives:

# To detect request directs:
curl -sI | head -1 | egrep '301|302|307' | wc -l

# To create a POST request:
curl -d "item=bottle&category=consumer&submit=ok"

# To create a HTTP Basic auth request:
curl -u username:password

# To follow redirected URL's:
curl -L

# To specify a proxy server:
curl -U : --proxy-ntlm --proxy -O

# To set the referer:
curl -e

# To set the user-agent:
curl -A "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.112 Safari/534.30"

# To fetch response headers:
curl -I

# To fetch response headers:
curl --head

# To fetch response headers and body:
curl -i

# To dump response headers to file:
curl --dump-header headers.txt

# To download a file using FTP:
curl -u ftpuser:ftppass -O ftp://ftp_server/public_html/xss.php

# To get an FTP directory listing:

# To get an FTP directory listing for a specific directory:
curl -u ftpuser:ftppass -O ftp://ftp_server/public_html/

# To upload a file with FTP:
curl -T uploadfilename -u username:password
curl -T uploadfilename -u username:password

# To get an FTP list and download files using ranges:

# To FTP upload multiple files at a same time using ranges:
curl -u ftpuser:ftppass -T "{file1,file2}"

# To get user input, and save contents to ftp as `myfile_1.txt`:
curl -u ftpuser:ftppass -T -

# To enable a full-trace dump of all incoming/outgoing data:
curl -v --trace -

# To specify a proxy server and download a file:
curl -x

# To send mail using SMTP Protocol (note: type . (period) as the last to send):
curl --mail-from --mail-rcpt smtp://

# To get network info:
curl        # ip
curl   # hostname
curl     # user agent
curl<port> # open port check
curl    # all

# To continue/resume a previous download:
curl -O      # ctl+c to stop the dl
curl -C - -O # continue the dl

# To limit the rate of data transfer (1000 bytes/second):
curl --limit-rate 1000B -O \

# To download a file if modified before/after the given date and time:
curl -z 21-Dec-11  # if modified `later` than the given date and time
curl -z -21-Dec-11 # if modified `before` the given date and time

# To resume a failed download:
curl -C - -o partially_downloaded_file ''

# To get the population of the US (in JSON):
curl --silent ',GEONAME&for=us:*' | python -c 'import json,sys;obj=json.load(sys.stdin);print obj[1][0]'

# To get the population of the world (in JSON):
curl --silent | python -c 'import json,sys;obj=json.load(sys.stdin);print obj["world"]["population"]'

# To download all images from a 4chan thread (first grep all href images then sed the url part then wget):
curl --silent $1 | grep -o -i '<a href="//[^>]*>' | sed -r 's%.*"//([^"]*)".*%\1%' | xargs wget

# To store and reuse cookies (i.e.: for logging into web site):
curl -L -d "uid=<username>&pwd=<password>" -c cookies.txt

# To debug redirects between production reloads:
#   watches the headers of a curl, following any redirects and printing only
#   the HTTP status and the location of the possible redirects
watch 'curl -s --location -I | grep -e "\(HTTP\|Location\)"'

# To check if a web server supports gzip compression:
curl -I -H "Accept-Encoding: gzip,deflate"

# To get the external IP and network info (as json):

# To download a file from SFTP:
curl -u username s

# To download a file using SSH and SCP (secure copy), and a private key for authentication:
curl -u username: --key ~/.ssh/id_rsa --pubkey ~/.ssh/ \

# To get a remote resource file size in bytes:
curl -sI | awk '/Content-Length/ { print $2 }'