cUrl list of the most used and pratical commands of the powerful open source networking tool

What is cUrl 

cUrl is an open source object programming language, it’s very useful in web applications where a strong inter-compatibility between protocols and documents is required. 

 

In particular, it avoids the developer having to use multiple programming languages, making  a single framework available in a series of functions combined between markup (HTML or JS) and computational languages (Java, C#, C++…). 

 

cUrl consists of a package and provides tools and a command line to operate on the NET using URL syntax. 

It supports many protocols, such as Gopher, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, DICT, FILE, FTP, FTPS, Gopher, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMTP, SMTPS, Telnet e TFTP. 

The official website http://curl.haxx.se/ is where you can download the packages.
Needless to say, it runs on practically any platform. 

 

The commands you need to know 

 

Download a file 

$ curl http://www.spaceclick.com 

To save,  

$ curl http://www.spaceclick.com > sc-com.html 

 

Download a file only if it has been modified before/after a certain date 

After the date 

$ curl -z 20-Dec-14 http://www.spaceclick.com/aprettyfile.html 

Before the date 

$ curl -z -20-Dec-14 http://www.spaceclick.com/aprettyfile.html 

 

Download files via FTP 

$ curl -u ftpuser:ftppass -O ftp://ftpserver/public/abcd.php 

to download a folder, 

$ curl -u ftpuser:ftppass -O ftp://ftpserver/public/ 

 

Restore interrupted downloads 

to interrupt a large download you can use Ctrl+C to resume, 

curl -C - -O http://www.spaceclick.com/bigfile.ext 

 

Save the output to a file 

curl -o aprettyfileNAME.html http://www.spaceclick.com/aprettyfile.html 
curl -O http://www.spaceclick.com/aprettyfile.html 

with the -O option the name will be the same as the origin 

Request multiple files at the same time 

$ curl -O URL1 -O URL2 

 

Limit the download speed 

$ curl --limit-rate 1000B -O http://www.spaceclick.com/bigfile.ext 

in this case it’s limited to 1000 Bytes/s 

 

Download a series of files based on a character pattern 

$ curl   ftp://ftp.spaceclick.com/files/[a-z]/ 

 

Follow HTTP routes via their response 

$ curl http://www.spaceclick.com 

you can force the redirects with the -L option, 

curl -L http://www.spaceclick.com 

 

Authentication via HTTP (base auth) 

$ curl -u username:password URL 

 

Uploading files to an FTP server 

$ curl -u ftpuser:ftppass -T filename.txt ftp://ftp.server.com 

to load multiple files, 

$ curl -u ftpuser:ftppass -T "{file1,file2}" ftp://ftp.server.com 

 

Enable Verbose mode 

simply enter the option -v, es: 

$ curl -v http://www.spaceclick.com 

 

Use the DICT protocol 

$ curl dict://dict.org/d:bash 

 

Send an email via SMTP protocol 

$ curl --mail-from aname@abcd.com --mail-rcpt foo@xyz.com smtp://mailserver.com 

afterwards you will be asked for object and body, insert them as follows, with the dot as the terminator 

Subject: Test email (subject) 

This is a body test 

. 

 

Download a file via PROXY 

use the option -x 

$ curl -x proxysever.domain.com:3128 http://www.spaceclick.com 

 

As you can see cUrl is a very versatile and interesting bookshelf, make good use of it! 

Share on Social Media
Scroll to Top