Welcome to pay attention to how to use the curl
tool to download a file. When you run the curl command, you get an error saying curl command not found
. Don't worry, this simply tells you that curl
is not installed on your Ubuntu machine.
Curl is a command line tool that allows you to pass data between local and remote servers. With curl
, you can use any of the supported protocols to download or upload data. These protocols include HTTP, HTTPS, SCP, SFTP, and FTP.
In this guide, we will show you how to install Curl on Ubuntu 18.04.
Curl is included in the default Ubuntu 18.04 software source. The installation process is straightforward, just enter:
sudo apt install curl
To verify whether curl
is installed, type curl
in the terminal and press the Enter key Enter
:
curl
The output should look like this:
curl:try'curl --help' or 'curl --manual'for more information
that's it! At this point, you have successfully installed curl on your Ubuntu system.
If no parameter options are used, Curl will output the resource specified by url on the standard output interface.
For example, the following command will print the source code of the example.com
homepage in your terminal window:
curl https://example.com
To download a file using Curl, you can use -o
or -O
. The lowercase -o
allows you to specify the save file name of the file you download:
curl -o linux.tar.xz https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.0.5.tar.xz
The uppercase -O
will save the file with the original file name.
curl -O https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.0.5.tar.xz
Another useful feature of Curl is to get only HTTP headers:
curl -I https://www.ubuntu.com/
HTTP/1.1200 OK
Date: Tue,02 Apr 201920:47:44 GMT
Server: gunicorn/19.9.0
Strict-Transport-Security: max-age=15768000
X-Hostname: juju-prod45-ubuntu-website-machine-15
Content-Type: text/html; charset=utf-8
Age:42
X-Cache: HIT from privet.canonical.com
X-Cache-Lookup: HIT from privet.canonical.com:80
Via:1.1 privet.canonical.com(squid/3.5.12)
Using Curl, you can also download files from a password-protected FTP server:
curl -u FTP_USERNAME:FTP_PASSWORD ftp://ftp.example.com/file.tar.gz
You have successfully installed Curl on your Ubuntu system. For more information about the most commonly used options of curl, refer to: Curl Command Examples.
Recommended Posts