Download files on Linux using curl


curl is a command-line utility for transferring data from or to a server designed to work without user interaction. With curl, you can download or upload data using one of the supported protocols including HTTP, HTTPS, SCP , SFTP , and FTP . curl provides a number of options allowing you to resume transfers, limit the bandwidth, proxy support, user authentication, and much more.

Installing Curl

The wget package is available on most Linux distributions. To check if the wget package is present on your system by running the following command:

 curl --version

If the wget package is not available on your system, you can easily install it as follows:


apt-get install curl

Centos 7:

yum install wget -y

yum install curl -y

Centos 8:

dnf install curl -y

Curl command example

  • The curl command will get the content of the URL and display the following output:

[[email protected] ~]#  curl 

  • Save the Output to a File

[[email protected] ~]# curl -o test.html

Through the results of the above command, we see that the page will be saved in a file named test.html.

Uppercase -O saves the file with its original filename:
[[email protected] ~]# curl -O

  • Download Multiple files

You can resume a download by using the -C – option. This is useful if your connection drops during the download of a large file, and instead of starting the download from scratch, you can continue the previous one.

[[email protected] ~]# curl -O

and suddenly your connection drops you can resume the download with:

[[email protected] ~]# curl -C - -O

  • Get the HTTP Headers of a URL

HTTP headers are colon-separated key-value pairs containing information such as user agent, content type, and encoding. Headers are passed between the client and the server with the request or the response.

[[email protected] ~]# curl -I --http2

  • Download files from FTP servers with or without authentication

If downloading the file from an FTP server at ftp://ftpserver, the following command will download the file to your current working directory.

[[email protected] ~]# curl -u username:password -O ftp://ftpserver/

The username:password option can be omitted if the FTP server allows anonymous login.

  • Upload files to an FTP server

[[email protected] ~]#  curl -u username:password -T ocalfile.tar.gz ftp://ftpserver/

  • Using Proxies

curl supports different types of proxies, including HTTP, HTTPS and SOCKS. To transfer data through a proxy server, use the -x (–proxy) option, followed by the proxy URL.

[[email protected]~]# curl -x

If the proxy server requires authentication, use the -U (–proxy-user) option followed by the user name and password separated by a colon (user:password):

[[email protected]~]# curl -U username:password -x

Click here to buy our VPS!


On this page