Linux cURL Commands: Quick Tutorial


cURL is a command line interface tool used to download data from the internet. It is free to use, open source,  developed and maintained by thousands of contributors from all over the world. It supports numerous protocols such as HTTP, HTTPS, DICT, FILE, FTP, FTPS, Gopher, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMB, SMBS, SMTP, SMTPS, Telnet, and TFTP. Refer official website (https://curl.haxx.se/) for more details.

(1) Download content of the url

#curl https://allabouttesting.org

 

(2) To save the content of the url in the html file

#curl https://allabouttesting.org > test.html

 

It also shows statistics related to downloading speed of the content test.html of url. You can easily check the content of test.html by using cat command.

Alternatively, you can use below command for saving the content of url.

#curl -o test.html https://allabouttesting.org/what-is-unified-threat-management/

(3) Download pdf, iso image, installer file etc. from the url. In below example, we have downloaded user manual of curl command available on official website.

#curl -o test https://legacy.gitbook.com/download/pdf/book/bagder/everything-curl

 

Note: Remember we can also use wget command for download the file from the internet.

(4) To see the weather report of your city

#curl http://wttr.in/delhi

 

(5) Download content of multiple urls at same time

#curl -o file1 www.google.com -o file2 www.yahoo.com

 

(6) To check the header information of the url

#curl -I www.google.com

 

(7) To continue/resume the previous download

Assume you are downloading an official usage guide of curl command. Somehow it got cancel in the middle, you can continue downloading by using -C option as mentioned below.

#curl -0 everything-curl https://legacy.gitbook.com/download/pdf/book/bagder/everything-curl

Somehow it got cancel in the middle, you can continue downloading by using -C option as mentioned below.

#curl -o everything-curl -C  - https://legacy.gitbook.com/download/pdf/book/bagder/everything-curl

(8) To control the download speed of file

#curl --limit-rate 1000B -o filename https://legacy.gitbook.com/download/pdf/book/bagder/everything-curl

 

(9) To enable the verbose mode

#curl -v www.google.com

 

(10) To interact with API endpoints

In below example, you can get information regarding ip address by using ipinfo.io

#curl ipinfo.io/X.X.X.X

X.X.X.X denotes the ip address.


Subscribe us to receive more such articles updates in your email.

If you have any questions, feel free to ask in the comments section below. Nothing gives me greater joy than helping my readers!

Disclaimer: This tutorial is for educational purpose only. Individual is solely responsible for any illegal act.

Comments:

Your email address will not be published. Required fields are marked *

 
error: