curl command usage short guide
Curl
Curl is a tool for data transfer. It supports a variety of protocols - HTTP, HTTPS, FTP, SFTP, TFTP, IMAP, POP3, SCP, SMTP and a bunch of other protocols, full list is available in man output.
It is tiny, flexible, could provide verbose information, good for automation, since user interaction witch curl is not needed.
Curl usage
Syntax is simple:
1
2
3
$ curl [options] [URL]
The basic request to GitHub would be look like:
1
2
3
$ curl github.com
Downloading files with the same name, as in the URL
1
2
3
$ curl -O [URL]
Or with specific file name:
1
2
3
$ curl -o [filename] [URL]
Continue downloading of stopped download is possible with “-C” parameter
1
2
3
$ curl -C -O [URL]
Verbose output
1
2
3
4
5
$ curl -v [options] [URL]
$ curl --verbose [options] [URL]
Authenticate on remote server
1
2
3
$ curl -u {username}:{password} [URL]
For example, download FTP file with authentication would look like:
1
2
3
$ curl -u ftpuser16:Password111 -O ftp://example.com/bugrep.tgz
File upload:
1
2
3
$ curl -T -u {username}:{password} [URL]
Progress bar:
It is possible to change curl meter to progress bar:
1
2
3
4
5
$ curl -# [URL]
$ curl --progress-bar [URL]
Or disable any progress information:
1
2
3
4
5
$ curl -s [URL]
$ curl --silent [URL]
HTTP and HTTPS:
Include HTTPS headers to output
1
2
3
4
5
$ curl -i https://github.com
$ curl --include https://github.com
Specify HTTP-request type:
1
2
3
$ curl --request [request type] [options] [URL]
Example
1
2
3
$ curl --request GET https://github.com
Proxy server also could be specified:
1
2
3
curl -x [proxy address]:[port] [URL]
If proxy server requires authentication, curl can be used with next command:
1
2
3
4
5
curl -x [proxy address]:[port] -U [user]:[password] [URL]
curl -x [proxy address]:[port] --proxy-user [user]:[password] [URL]
SMTP
If you do not like to send emails via telnet you could use curl
1
2
3
$ curl –url [SMTP URL] –mail-from [sender address] –mail-rcpt [recipient address] -n –ssl-reqd -u {email}:{password} -T [mail text file]