How to install curl command on Ubuntu Linux

I am a new Ubuntu Linux user. I switched from Apple MacOS/Macbook and I am trying to run the curl command from a shell script but getting the following error:
bash: curl: command not found
How do I fix this on an Ubuntu Linux version 17.10/19.04/20.10/16.04/18.04/20.04 LTS?

curl command is a tool to download or transfer files/data from or to a server using FTP, HTTP, HTTPS, SCP, SFTP, SMB and other supported protocols on Linux or Unix-like system.
Tutorial requirements
RequirementsUbuntu Linux
Root privileges Yes
Difficulty Easy
Est. reading time 2m
Installing curl on anfswssssssssssss Ubuntu Linux
One can easily install and use the curl command on a Ubuntu Linux using the apt command or apt-get command to use the curl.

Installing cURL for Ubuntu Linux

The procedure to install cURL on Ubuntu Linux is as follows:

  1. Update your Ubuntu box, run: sudo apt update && sudo apt upgrade
  2. Next, install cURL, execute: sudo apt install curl
  3. Verify install of curl on Ubuntu by running: curl --version

Let us see all commands in details with examples.

Ubuntu install curl command

First update the system and get latest stable curl version for Ubuntu:
$ sudo apt update
$ sudo apt upgrade

Type the following apt command or apt-get command:
$ sudo apt install curl
Sample outputs:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  libcurl4
The following NEW packages will be installed:
  curl libcurl4
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 373 kB of archives.
After this operation, 1,036 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://in.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libcurl4 amd64 7.58.0-2ubuntu3.7 [214 kB]
Get:2 http://in.archive.ubuntu.com/ubuntu bionic-updates/main amd64 curl amd64 7.58.0-2ubuntu3.7 [159 kB]
Fetched 373 kB in 2s (150 kB/s)
Selecting previously unselected package libcurl4:amd64.
(Reading database ... 164985 files and directories currently installed.)
Preparing to unpack .../libcurl4_7.58.0-2ubuntu3.7_amd64.deb ...
Unpacking libcurl4:amd64 (7.58.0-2ubuntu3.7) ...
Selecting previously unselected package curl.
Preparing to unpack .../curl_7.58.0-2ubuntu3.7_amd64.deb ...
Unpacking curl (7.58.0-2ubuntu3.7) ...
Setting up libcurl4:amd64 (7.58.0-2ubuntu3.7) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Setting up curl (7.58.0-2ubuntu3.7) ...

Verification

Run the following command:
$ curl --version
Ubuntu install curl command and verify it

Usage

Once installed you can use it as follows to see the headers:
$ curl -I https://www.google.co.in/
$ curl -I https://www.cyberciti.biz/

Sample outputs:

HTTP/2 200 
date: Mon, 29 Jul 2019 13:13:08 GMT
content-type: text/html; charset=UTF-8
set-cookie: __cfduid=d5292058141c28e3cda2d9501688cff531564405988; expires=Tue, 28-Jul-20 13:13:08 GMT; path=/; domain=.cyberciti.biz; HttpOnly; Secure
vary: Accept-Encoding
strict-transport-security: max-age=15552000
x-whome: l-cbz02
cf-cache-status: HIT
age: 102433
x-content-type-options: nosniff
expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
server: cloudflare
cf-ray: 4fdf59334ab9dcb5-MAA

Or download a file from a server using curl itself:
$ curl -o output.file http://server1.cyberciti.biz/bar.foo.txt
You can resume broken download with the curl command as follows:
$ curl -L -O -C - http://ftp.ussg.iu.edu/linux/centos/latest/isos/file.iso
Change user agent while accessing the url:
$ curl -A "USER-AGENT" url
$ curl -A 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:77.0) Gecko/20100101 Firefox/77.0' https://www.cyberciti.biz

Passing HTTP referer is easy too:
$ curl --referer https://www.cyberciti.biz https://www.nixcraft.com
In this example, upload a ‘.doc’ file (HTTP POST request) using the curl command:
$ curl -F 'file_name=@/home/vivek/Documents/sales.doc https://server1.cyberciti.biz/mycloud/

Finding curl version and feature sets

Simply run:
$ curl --version
Version details:

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

Conclusion

This page explained how to install curl command on an Ubuntu Linux system. For more info see curl home page:


🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 1 comment so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersncdu pydf
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
1 comment… add one
  • Baby fox Feb 27, 2021 @ 9:58

    Yo busqué “How to Install Curl in Linux” y esto me fue útil.

    Muchas gracias señor.

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum