How to download a file using cURL on Linux?

Download A File In The Terminal Using The CURL Command

While wget is the most commonly used utility to download files, cURL and aria2 can be used to achieve the same results as well.

cURL works both as a command line utility and a library and therefore you can use it to download and transfer any kind of data over different protocols such as HTTPS, SFTP, HTTP, FTP and many more. In this tutorial, I will show you the different use cases of this command line tool with examples, so fasten your seatbelts and let’s get started!

Also read – The Difference between Wget and cURL command

Using cURL to download a file.

Simply type the following command if you wish to download a file without any extra parameters :

curl https://your-domain/application.exe

If you want to specify any protocol, then you can type :

curl sftp://sftp-website-name/file.txt

Let’s say you want to follow a 301-redirected file while downloading, you can use the -L flag :

curl -L http://a-website/sourcecode.tar.gz
Using Curl To Download A File
Using Curl To Download A File

You can also download a file and immediately rename it using -o flag like this :

curl -L -o file.txt http://sample-website/

For example, let’s download an application named Freetube from GitHub :

Downloading A File And Renaming It
Downloading a file and renaming it immediately

You can also apply a speed limit to your downloads using the –limit-rate flag. For example :

curl -L -O --limit-rate 1m
The Download Took Some Time Because Of The Speed Limit
The Download Took Some Time Because Of The Speed Limit

In the above example, I have set the download rate to not exceed 1MB per second.


cURL is a really lightweight tool full of features that any other terminal-based downloader might not have. However, to read more about its functions, you should definitely check out the manual page of this command, just type :

man curl
Manual Page Of The Curl Command
Manual Page Of The Curl Command