The curl command is used to transfer data to or from a remote server. With the help of the curl command-line tool, you can upload and download data using different network protocols, such as HTTPS, HTTP, SFTP, Telnet, and FTP.
Most of the time, when you are trying to download a file through the curl command, you get an error message saying the curl command is not found. In this situation, you need to install the curl package on your CentOS or any other Linux distribution.
We will give instructions on how to install the curl command on CentOS 8 system in this article. We will show the use of the curl command on CentOS or Linux machines.
Installation of Curl packages on CentOS 8
The curl command can be installed directly from the default CentOS 8 packages repository. Open the terminal from the left sidebar of the ‘Activities’ section and update the system cache by running the following command:
$ sudo dnf makecache
Once the repository is updated, issue the following command to install the curl packages on your CentOS 8 system. If curl is not installed then, all curl packages will be installed from the CentOS 8 repository.
$ sudo dnf install curl
If curl is already installed on your system then, the following output will display on the terminal.
Verify the curl installation by typing the following command in the terminal:
The following output should show on the terminal if curl is installed on your system:
Display the installed version of the curl command by using the following command:
$ curl --version
Use of the curl command on Linux system
The curl command is a very useful command-line utility. Using the curl command, you can view the source code of a given URL in a standard output format as follows:
$ curl https://linuxways.net
To get the HTTP header details of the given URL, type the following command:
$ curl -I https://linuxways.net
Using the curl command, you can download a file from a given URL and use option -o in lowercase to save a file with a name. Use the following command syntax to download a file through the curl command:
$ curl -o newfile-name.zip http://domain.com/filename.zip
Use the uppercase -O to save a file with its original name in your system as follows:
$ curl -O http://domain.com/filename.zip
Through the curl command, you can also access the password-protected files from the FTP server using the -u option. For this purpose, use the following syntax:
$ curl -u FTP_user-name:FTP_password ftp://ftp.domain.com/filename.zip
We have seen in this article how to install the Curl command-line tool on CentOS 8 system. Through the curl command, users can download and upload files over the network. We have explored different uses of the curl command on CentOS 8 system. If you need to get more information about this command-line tool then, explore more curl examples on the internet. Give your suggestions through comments. Thanks!