
Curl is a command line utility for transferring data from or to a remote server. It allows you to download or upload data using HTTP, HTTPS, SCP , SFTP , and FTP protocols .
If you try to download the file using curl
and get an error message saying curl command not found
, which means that the curl package is not installed on your CentOS System.
This guide explains How to Install and Use Curl on Rocky Linux 9 and Alma Linux 9.
Install Curl on Rocky Linux 9 and Alma Linux 9
The packages curl
are in the default Rocky Linux 9 and Alma Linux 9 repositories, to install them run the following command:
sudo dnf install curl
To verify that curl
it is installed, type curl
in the terminal and press Enter:
curl
The command will print the following output:
curl: try 'curl --help' or 'curl --manual' for more information
At this point, you have successfully installed curl on your Debian machine, and you can start using it.
Start Using Curl
When used without any options, curl will print the URL source code specified as an argument to standard output, for example:
curl https://example.com
To download a file using curl, use the flag -o
or-O.
The option -o
(lower case o) 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
The option -O
(the letter o in uppercase) will save the file with its original filename:
curl -O https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.0.5.tar.xz
Another useful feature of Curl is its ability to display the HTTP headers of a given URL:
curl -I https://www.centos.org/
HTTP/1.1 200 OK Date: Thu, 13 Feb 2020 22:01:04 GMT Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips Strict-Transport-Security: max-age=31536000 X-Frame-Options: SAMEORIGIN X-Xss-Protection: 1; mode=block X-Content-Type-Options: nosniff Referrer-Policy: same-origin Last-Modified: Thu, 06 Feb 2020 17:21:08 GMT ETag: "5421-59deb7fadfdfd" Accept-Range: bytes Content-Length: 21537 Content-Type: text/html; charset=UTF-8
With 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
Conclusion
Curl is a versatile tool that allows you to send and receive data over a network. Installing Curl on Debian is a fairly simple task.
For more information on how to use this tool, visit Curl Command Sample
Leave a Reply