Home Linux How to Install Curl in Ubuntu

How to Install Curl in Ubuntu

by admin
install curl on ubuntu linux screenshot

cURL (Client URL Library) is a command-line tool for transferring data using various network protocols, typically HTTP/s, though it supports many more including ftp, scp and smb. Curl has been around for quite a while – it was first released in 1996 (though back then it was called httpget).

cURL is a command-line tool for getting or sending data including files using URL syntax. If you are a Linux user there is a good chance you have come across it at some point. Curl is often used as a way to download files from the internet, although it is capable of much more.

Quite often it can be found on most Linux distributions, or if not it is straight forward to install it. This article shows you how to install curl on Ubuntu systems if it isn’t already present, and gives some simple examples to show you how to use curl and confirm that it is working as expected.

Install Curl on Ubuntu

To use cURL, you can simply type curl at a bash shell prompt. If you see a message such as the one shown below then curl isn’t currently installed on your system:

$ bash: curl: command not found

The good news is that since curl is included in Ubuntu’s (or generally most distributions) main repository, which means it’s very easy to install. Before we do though it’s advisable to update the systems package cache first:

$ sudo apt update

Often this will resolve any issues such as seeing a “unable to locate package curl” message. Once the cache has updated we can install curl using the apt install curl command:

$ sudo apt install curl
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
  curl
0 upgraded, 1 newly installed, 0 to remove and 62 not upgraded.
Need to get 161 kB of archives.
After this operation, 412 kB of additional disk space will be used.
Get:1 http://eu-west-2.ec2.archive.ubuntu.com/ubuntu focal-updates/main amd64 curl amd64 7.68.0-1ubuntu2.7 [161 kB]
Fetched 161 kB in 0s (1672 kB/s)
Selecting previously unselected package curl.
(Reading database ... 200280 files and directories currently installed.)
Preparing to unpack .../curl_7.68.0-1ubuntu2.7_amd64.deb ...
Unpacking curl (7.68.0-1ubuntu2.7) ...
Setting up curl (7.68.0-1ubuntu2.7) ...
Processing triggers for man-db (2.9.1-1) ...

All done already! We can check it’s installed correctly by running curl –version:

$ curl --version
curl 7.68.0 (x86_64-pc-linux-gnu) libcurl/7.68.0 OpenSSL/1.1.1f zlib/1.2.11 brotli/1.0.7 libidn2/2.2.0 libpsl/0.21.0 (+libidn2/2.2.0) libssh/0.9.3/openssl/zlib nghttp2/1.40.0 librtmp/2.3
Release-Date: 2020-01-08
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp scp sftp smb smbs smtp smtps telnet tftp
Features: AsynchDNS brotli GSS-API HTTP2 HTTPS-proxy IDN IPv6 Kerberos Largefile libz NTLM NTLM_WB PSL SPNEGO SSL TLS-SRP UnixSockets

Great stuff! cURL is now installed and working as expected. Note that whilst we are talking mainly about Ubuntu in this article, the same commands should work on other Debian based distributions. Typically on other disstributions such as Centos or Fedora, you can use yum:

$ sudo yum install curl

Finally, lets test the curl install by asking it to fetch some data from the internet. In this example, we’re going to fetch the http header from www.ubuntu.com:

$ curl -I --http2 https://www.ubuntu.com/
HTTP/2 301
server: nginx/1.14.0 (Ubuntu)
date: Thu, 13 Jan 2022 17:10:18 GMT
content-type: text/html
content-length: 175
location: https://ubuntu.com/
link: <https://assets.ubuntu.com>; rel=preconnect; crossorigin, <https://assets.ubuntu.com>; rel=preconnect, <https://res.cloudinary.com>; rel=preconnect
x-cache-status: HIT from content-cache-gs2/1

All good! In this article you have learned how to install curl on Ubuntu Linux systems.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More