Download / Install Curl ( Ubuntu )

CURL – Client Uniform Resource Locator (Client-URL).

If we talk about its history – In 1997 curl was introduced but before naming it as curl it was called httpget and then urlget.
It was mainly developed for fetching currency exchange rates but later on its easy of use, flexibility, portability is widely used on all platforms for many purposes.

Why Use Curl ?

It is mainly used to send and get the data information using URL syntax which support almost
all the protocols and all the available platforms.

Here are few list of protocols mainly used.
HTTP, HTTPS, FTP, FTPS, IMAP, IMAPS, POP3, IMAP, SMTP, TELNET and many more.

Curl Advantages:

  • Easy to use and flexible.
  • Console logs of downloads.
  • Compactibility with all protocols.
  • Download multiple files
  • Access remote servers for download upload files.
  • Using curl we can login into websites

Here today we will see how to install curl on Ubuntu:

Step 1 : Open terminal and update the Ubuntu apt with the following command

sudo apt update
sudo apt install software-properties-common

Note : apt is a advanced package tool which helps to install or remove the soft wares on Linux.

apt update
Apt Update

Step 2 : Check for any system upgrade – this is optional as it can take more then 5 to 10 minutes for upgrade.

sudo apt upgrade
System Upgrade
System Upgrade

Step 3 : Install the curl with apt command

sudo apt install curl
Install Curl
Install Curl

Step 4 : Verify the installation with following command.

curl --version
Curl Version
Curl Version

Once version details are displayed properly indicates that curl is being installed successfully.

Step 5 : We can also verify with quick example how curl works with following few commands.

a) Get Command : This will fetch the site and print http response in the console.

curl https://www.google.com
Curl Get Command
Curl Get Command

b) Return Http Headers : Using -I option which will only fetch HTTP headers of the url.

curl -I https://www.google.com/
Curl Return Headers
Curl Return Headers
curl -0 www.example.com/file.css

In this way using -O option file.css will be created and out put will saved to it.

c) To Store Http Headers :

curl -D - https://www.google.com/

Here option -D stores the http headers and – option after -D will write Http headers into output file.

d) To Resume the download :

curl -C - -O https://www.google.com/img/sample.png

While downloading if something wents wrong and download is interuptted or unfortunately stopped then it can be resume.
-C option will help to resume the downloading.

e) Help curl :

curl -h

Using -h option to get help commands.

f) Curl Requests :

curl -X POST http://example.com/login/ -d 'username=raghavendra&password=raghav1984'

Using option -d we can request http method and post the data to any pages.
Example : login page

g) Method (GET) :

curl --request GET https://www.example.com

Using GET method to fetch the date from URL.

h) Method (POST) :

curl --request POST https://www.example.com

Using POST method to Post the date to any server with URL.

f) Method (DELETE) :

curl --request DELETE https://www.example.com

Using DELETE method to delete the data from any web server with URL

g) Method (PUT) :

curl --request PUT https://www.example.com

Using PUT method to create new page or update.

Hope this information was helpful to you.
Feel free to comment if you face any issues or have any doubts.

Leave Your Reply

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