curl
is a powerful command line tool, mainly used to transfer data between local and remote servers. Using curl
you can download or upload data using various protocols, such as: HTTP, HTTPS, SCP, SFTP, and FTP.
If you try to use curl
to download a file and get an error message, "curl command not found", it means that the curl
package is not installed on your CentOS machine.
This article provides instructions on how to install and use the curl
command on CentOS 8.
The Curl package is available in the CentOS 8 source repository. To install it, run the following command:
sudo dnf install curl
Once the installation is complete, verify it by typing curl
in the terminal:
curl
The output should look like this:
curl:try'curl --help' or 'curl --manual'for more information
that's it! curl
has been installed on your CentOS system, and you can start using it.
When you do not use any options, curl
will print out the source code of the provided URL:
curl https://example.com
When you want to use curl
to download a file, use the -o
or -O
option and add the URL address after the file name.
The lowercase -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.5.3.tar.xz
The uppercase -O
saves the file using the source file name.
curl -O https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.5.3.tar.xz
When using the -I
option, curl
will print out the HTTP header information of the provided URL:
curl -I https://www.centos.org/
HTTP/1.1200 OK
Date: Thu,13 Feb 202022: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 202017:21:08 GMT
ETag:"5421-59deb7fadfdfd"
Accept-Ranges: bytes
Content-Length:21537
Content-Type: text/html; charset=UTF-8
Using 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
curl
is a versatile tool that allows you to send or receive data over the network.
To learn more about how to use this tool, browse: Curl Command Examples.
Recommended Posts