Linux

How to Install and Use a Curl on Ubuntu 20.04

How to Install and Use a Curl on Ubuntu 20.04

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:

curl

The output will look like this:

Output :

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.

Use curls

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:

curl https://gnu.org

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/

Output :

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

Conclusion

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.

Related posts

How to make a POST request with cURL

Linux

How to install CMake on Ubuntu

Linux

How to Install Ubuntu on a Raspberry Pi

Linux

How to Install a Plex Media Server on Ubuntu 20.04 / Linux Mint 20

Linux

Fedora 31: How to Install Fuel CMS with Nginx

Howto

How to Add Elements to a List in Python (add, add and enter)

Linux

How to Install Puppets on CentOS 8 / RHEL 8

Linux

How to Manage Nginx Server Blocks on Ubuntu 20.04

Linux

What You Need to Know About Locked in Ubuntu 20.04

Linux