curl is a command line utility for transferring data from or to a remote server. With curl, you can download or upload data using one of the supported protocols, including HTTP, HTTPS, SCP, SFTP, and FTP.
This article explains how to install Curl on Ubuntu 20.04.
Install Curl on Ubuntu
If you get an error saying the curl command was not found when trying to download a file with curl, that means the curl package is not installed on your Ubuntu machine.
curl is included in the default Ubuntu 20.04 repository. Installation is quite easy:
sudo apt update
sudo apt install curl
After the installation is complete, verify by typing curls in your terminal:
The output will look like this:
curl: try 'curl --help' or 'curl --manual' for more information
There she is! You have successfully installed curl on your Ubuntu machine, and you can start using it.
When used without any options, the curl prints the source code of the URL specified as an argument to standard output.
For example, the following command prints the gnu.org homepage source in your terminal window:
To download files with curl, use the -o or -O options.
The lowercase -o option allows you to specify the name of the saved file:
curl -o linux.tar.xz https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.0.5.tar.xz
When called with an uppercase -O, curl saves the file with its original file name:
curl -O https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.0.5.tar.xz
With curls you can also retrieve only HTTP headers from the specified URL:
curl -I https://www.gnu.org/
HTTP/1.1 200 OK Date: Mon, 29 Jun 2020 07:10:35 GMT Server: Apache/2.4.7 Content-Location: home.html Vary: negotiate,accept-language,Accept-Encoding TCN: choice Strict-Transport-Security: max-age=63072000 Access-Control-Allow-Origin: (null) Accept-Ranges: bytes Cache-Control: max-age=0 Expires: Mon, 29 Jun 2020 07:10:35 GMT Content-Type: text/html Content-Language: en
The most common case for curling is downloading files from a password-protected FTP server:
curl -u FTP_USERNAME:FTP_PASSWORD ftp://ftp.example.com/file.tar.gz
Curl is a versatile tool that allows you to send and receive data over a network. Installing Curl on Ubuntu is a very simple task.
For more information about using this tool, visit Sample Curl Commands.
If you have questions or feedback, don’t hesitate to leave a comment.