
Curl tool is used for transfer data from or to a server. It can be use to download or upload files with one of the supported protocols including HTTP, HTTPS, SCP, SFTP, and FTP. This article explains how to install curl on CentOS 8 system.
The wget command is alternative way of curl to transfer the files. If you are trying to use curl command and get error message like bash: curl: command not found it means that the curl package is not installed on your CentOS machine.
Step 1 – Install Curl on CentOS
By default, CentOS repositories includes Curl package. Run the below command to install curl as root or user with sudo privileges:
sudo apt install curl
Step 2 – Verify Installation
Once the installation is finished, you can verify installation by typing curl
in your terminal:
curl
It should show output as below:
curl: try 'curl --help' or 'curl --manual' for more information
That’s it! You have successfully installed curl on your CentOS machine, and you can use it.
Step 3 – Using Curl
If you would like to view source code of any url simply follow url by curl
command and hit Enter
key:
curl https://google.com/
You can download file using -o
or -O
flags with curl command. By using lowercase -o
option you can specify the name of the saved file as given below:
curl -o go.tar.gz https://dl.google.com/go/go1.14.2.darwin-amd64.tar.gz
Option -O
(uppercase) will be used to store file with its original name:
curl -O https://dl.google.com/go/go1.14.2.darwin-amd64.tar.gz
Using curl you can see the headers of any given URL. Use the -I
option with curl to display the HTTP headers. For example, if you want to show headers of https://www.google.com/
run below command:
curl -I https://www.google.com/
It will show output as following:
HTTP/1.1 200 OK Date: Sun, 03 May 2020 11:49:57 GMT Expires: -1 Cache-Control: private, max-age=0 Content-Type: text/html; charset=ISO-8859-1 P3P: CP="This is not a P3P policy! See g.co/p3phelp for more info." Server: gws X-XSS-Protection: 0 X-Frame-Options: SAMEORIGIN Transfer-Encoding: chunked Alt-Svc: h3-Q050=":443"; ma=2592000,h3-Q049=":443"; ma=2592000,h3-Q048=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43" Accept-Ranges: none Vary: Accept-Encoding
To get more help for curl
command type man
command:
man curl
OR
curl --help
Conclusion
You successfully learned how to install Curl on CentOS 8 system. For more information about how to use this tool, visit Curl Command Examples.
If you have any questions or suggestion, feel free to leave comment below.
Leave a Reply