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/16.04/18.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.
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:
- Update your Ubuntu box, run: sudo apt update && sudo apt upgrade
- Next, install cURL, execute: sudo apt install curl
- Verify install of curl on Ubuntu by running: curl --version
Let us see all commands in details.
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
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
Conclusion
This page explained how to install curl command on an Ubuntu Linux system. For more info see curl home page: