Cyberithub

5 Easy Steps to Install curl command on Ubuntu 20.04

Advertisements

In this article, I will take you through 5 Easy Steps to install curl command on Ubuntu 20.04. curl is a free and open source utility in Linux based servers used to transfer data to or from remote Servers using supported protocol: HTTP, FTP, IMAP, POP3, SCP, SFTP, SMTP, TFTP, TELNET, LDAP or FILE. It is widely used by many developers and programmers around the world to perform API Testing. There are multiple ways to install curl command on Ubuntu 20.04 Server. Here we will see the most simplest one.

5 Easy Steps to Install curl command on Ubuntu 20.04

Easy Steps to Install curl command on Ubuntu 20.04

Also Read: 11 Useful whereis command examples in Linux

Step 1: Prerequisites

a) You should have a running Ubuntu 20.04 Server.

b) You should have sudo or root access to run privileged commands.

c) You should have apt utility installed in your Server.

Step 2: Update Your Server

In the first step, let's update all the installed packages to the latest version by using apt update command as shown below. This will download and install all the latest stable releases from Ubuntu Repo.

root@localhost:~# apt update
Hit:1 http://in.archive.ubuntu.com/ubuntu focal InRelease
Get:2 http://in.archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
Get:3 https://packages.microsoft.com/repos/edge stable InRelease [7,343 B]
Get:4 http://in.archive.ubuntu.com/ubuntu focal-backports InRelease [101 kB]
Get:5 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]
Get:6 http://ppa.launchpad.net/micahflee/ppa/ubuntu focal InRelease [17.5 kB]
Get:7 http://in.archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [1,033 kB]
Get:8 https://packages.microsoft.com/repos/edge stable/main amd64 Packages [5,959 B]
Get:9 http://in.archive.ubuntu.com/ubuntu focal-updates/main i386 Packages [491 kB]
Get:10 http://in.archive.ubuntu.com/ubuntu focal-updates/main Translation-en [230 kB]
Get:11 http://in.archive.ubuntu.com/ubuntu focal-updates/main amd64 DEP-11 Metadata [283 kB]
Get:12 http://in.archive.ubuntu.com/ubuntu focal-updates/main amd64 c-n-f Metadata [13.5 kB]
Get:13 http://in.archive.ubuntu.com/ubuntu focal-updates/universe amd64 Packages [785 kB]

 

Step 3: Install curl command

After successfully updating the Server, you can now install the curl utility by using apt install curl command as shown below. This will download and install the curl package from Ubuntu Repo along with its dependencies.

Advertisements
root@localhost:~# apt install curl
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following package was automatically installed and is no longer required:
libatomic1
Use 'apt autoremove' to remove it.
The following NEW packages will be installed:
curl
0 upgraded, 1 newly installed, 0 to remove and 145 not upgraded.
Need to get 161 kB of archives.
After this operation, 411 kB of additional disk space will be used.
Get:1 http://in.archive.ubuntu.com/ubuntu focal-updates/main amd64 curl amd64 7.68.0-1ubuntu2.5 [161 kB]
Fetched 161 kB in 1s (230 kB/s)
Selecting previously unselected package curl.
(Reading database ... 188229 files and directories currently installed.)
Preparing to unpack .../curl_7.68.0-1ubuntu2.5_amd64.deb ...
Unpacking curl (7.68.0-1ubuntu2.5) ...
Setting up curl (7.68.0-1ubuntu2.5) ...
Processing triggers for man-db (2.9.1-1) ...

 

Step 4: Using curl command

Once installed, you can test the curl command by sending requests to https://google.com using curl -I -L https://google.com command as shown below.

root@localhost:~# curl -I -L https://google.com
HTTP/2 200
content-type: text/html; charset=ISO-8859-1
p3p: CP="This is not a P3P policy! See g.co/p3phelp for more info."
date: Fri, 18 Jun 2021 14:32:05 GMT
server: gws
x-xss-protection: 0
x-frame-options: SAMEORIGIN
expires: Fri, 18 Jun 2021 14:32:05 GMT
cache-control: private
set-cookie: 1P_JAR=2021-06-18-14; expires=Sun, 18-Jul-2021 14:32:05 GMT; path=/; domain=.google.com; Secure
set-cookie: NID=217=GicefwuezVurmIEC4NF2pjXWiZKcKWFq803r4ZfEizcMCGsfu26BZclA88Y1zzetNudl64XFiMVNuayzbAl4dZCqumgVHDP_Lqg6EiEZTKVCKRbguvNiGw4XWbaYMNYwc2fgxREMgzzFUQ3MXAa8YbQeZ-ThkvkPyUP61GMNMgI; expires=Sat, 18-Dec-2021 14:32:05 GMT; path=/; domain=.google.com; HttpOnly
alt-svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000,h3-T051=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"

-I : Fetch the headers only. More on curl Man Page.

-L : If the server reports that the requested page has moved to a different location (indicated with a Location: header and a 3XX response code), this option will make curl redo the request on the new place.

Step 5: Uninstall curl command

Once you are done with curl utility, you can remove it from your Server using apt remove curl command as displayed below.

root@localhost:~# apt remove curl
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following package was automatically installed and is no longer required:
libatomic1
Use 'apt autoremove' to remove it.
The following packages will be REMOVED:
curl
0 upgraded, 0 newly installed, 1 to remove and 159 not upgraded.
After this operation, 411 kB disk space will be freed.
Do you want to continue? [Y/n] Y
(Reading database ... 188236 files and directories currently installed.)
Removing curl (7.68.0-1ubuntu2.5) ...
Processing triggers for man-db (2.9.1-1) ...

Leave a Comment