[ad_1]
curl
is a powerful command-line tool for transferring data from or to a remote server. With curl
you can download or upload data using various network protocols, such as HTTP, HTTPS, SCP
, SFTP
, and FTP
.
If you get an error message saying curl command not found
when trying to download a file with curl
, 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.
Installing curl
on CentOS #
Curl package is available in the standard CentOS 8 repositories. To install it run the following command:
sudo dnf install curl
Once the installation is complete, verify it by typing curl
in your terminal:
curl
The output should look something 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.
Using curl
#
When used without any option, curl
prints the source code of the given URL to the standard output:
curl https://example.com
To download a file with curl
, use either the -o
or -O
option, followed by the URLto the file.
The lowercase -o
option 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
Uppercase -O
saves the file with its original filename:
curl -O https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.5.3.tar.xz
When used with the -I
option curl
displays 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-Ranges: bytes
Content-Length: 21537
Content-Type: text/html; charset=UTF-8
With curl
you can also download files from FTP servers that are password protected:
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.
For more information about how to use this tool, check out Curl Command Examples
.
If you have any questions or feedback, feel free to leave a comment.
[ad_2]
Source link