Introduction
Curl is a command-line tool that is used frequently by Linux users. It is a useful utility that can be used to transfer data to or from a remote server.
The curl command supports many protocols: HTTP, HTTPS, SMTP, SCP, FTP, and so on.
This tool is designed for automatic operation, it can be used without user interaction.
This article will explain the way to install the Curl command on your Ubuntu 20.04 machine.
Installing Curl on Ubuntu 20.04
Open the terminal and enter the following command:
$ curl
If you encounter the output message as follows, it means the curl is not installed on your Ubuntu 20.04 machine.
You can install the curl by running:
$ sudo apt update
$ sudo apt install curl
To verify whether the curl is successfully installed, run:
$ curl --version
Output:
Getting started with curl
The most basic way to use the curl command is to run it without any option. The curl will display the source content of the target URL. For example:
$ curl https://linuxways.net
Output:
If you want to download files from remote servers with the curl command, let’s use the -o or -O options:
$ curl -O https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.10.11.tar.xz
To fetch only the HTTP headers, use the -I option:
$ curl -I https://linuxways.net
Output:
To transfer files via FTP protocol, you can use the curl command with the -u option and pass the username and password as shown below:
$ curl -u Ftp-user:Ftp-password ftp://ftp.domain.com
Conclusion
You’ve successfully installed and tried running some simple examples of the curl command on your Ubuntu 20.04 LTS machine.
If you have any concerns, feel free to leave your comment and let me know. Thank you!
System Engineer with 6 years of experience in software development, specializes in Embedded Linux, C/C++, Python, Go, and Shell Scripts. He has a solid background in Computer Networking, OpenStack, Kubernetes, Docker/Container, CI/CD, and Google Cloud as well. Now, he is Head of GDG Cloud Hanoi – a non-profit community of cloud developers who meet/share ideas on everything Google Cloud Platform related.