How to install and use Curl on CentOS 8

Curl is a command-line utility for transferring data to or from a remote server. It allows you to download or upload data using HTTP, HTTPS, SCP, SFTP and FTP protocols.

If you try to download files using curl And you get an error message that says curl command not found, Which means the curl package is not installed on your CentOS system.

This guide describes how to install and use commands curl On CentOS 8.

Install Curl on CentOS

Deal curl Located in the default CentOS 8 repository, to install it, run the following command:

sudo dnf install curl

To check it out curl Installed, type curl At 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 specified URL source code as an argument for standard output, for example:

curl https://example.com

To download files with curl, use the -o or -O.

Selection -o (The letter o in lowercase) 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

Selection -O (Capital o) will save the file with its original name:

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 HTTP headers from a specified 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-Ranges: 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 the network. Installing Curl on Debian is a fairly simple task.

For more information on how to use this tool, visit Examples of Curl Command

.

Source link

Leave a Reply

Your email address will not be published. Required fields are marked *