Linux Command line offers more flexibility and control than GUI. A number of people prefer to use command line than GUI because it is easier and quicker to use than GUI. Using the command line, it is easier to automate the tasks using one line. In addition, it utilizes fewer resources than GUI.

Downloading files is the routine task that is normally performed every day that can include file type like ZIP, TAR, ISO, PNG, etc. you can simply and quickly perform this task using command line terminal. It requires only using your keyboard. So today, I will show you how you can download a file using the command line in Linux. There are normally two known ways to do this, that is using wget and curl utility. For this article, I am using Ubuntu 18.04 LTS for describing the procedure.

Download files using Curl

Curl can be used to transfer data over a number of protocols. It supports many protocols including HTTP, HTTPS, FTP, TFTP, TELNET, SCP, etc. using Curl, you can download any remote files. It supports pause and resumes function as well.

To get started with, first, you need to install the curl.

Install curl

Launch command line application in Ubuntu that is Terminal by pressing the Ctrl+Alt+T key combinations. Then enter the below command to install curl with sudo.

$ sudo apt install curl

When prompted for a password, enter sudo password.

Install Curl

Once the installation is complete, enter the below command to download a file.

Download and save the file using the source file name

To save the file with the same name as the original source file on the remote server, use –O (uppercase O) followed by curl as below:

$ curl –O [URL]

Download file with curl

Instead of -O, you can also specify, “–remote-name” as shown below. Both work the same.

Cure remote-name option

Download and save the file with a different name

If you want to download the file and save it in a different name than the name of the file in the remote server, use -o (lower-case o) as shown below. This is helpful when the remote URL doesn’t contain the file name in the URL as shown in the example below.

$ curl –o [filename] [URL]

[filename] is the new name of the output file.

Download file using a different name

Download multiple files

To download multiple files, enter the command in the following syntax:

$ curl -O [URL1] -O [URL2]

Download multiple files at once

Download files from an FTP Server

To download a file from FTP server, enter the command in following syntax:

$ curl -O ftp://ftp.example.com/file.zip

Download file by FTP using curl on the command line

To download files from user authenticated FTP servers, use the following syntax:

$ curl -u [ftp_user]:[ftp_passwd] -O [ftp_URL]

Pause and resume download

While downloading a file, you can manually pause it using Ctrl+C or sometimes it automatically gets interrupted and stopped due to any reason, you can resume it. Navigate to the same directory where you have previously downloaded the file then enter the command in the following syntax:

$ curl –c [options] [URL]

Pause and resume downloads in curl

Download files using Wget

Using wget, you can download files and contents from Web and FTP servers. Wget is a combination of www and the get. It supports protocols like FTP, SFTP, HTTP, and HTTPS. Also it supports recursive download feature. This feature is very useful if you want to download an entire website for offline viewing or for generating a backup for static website. In addition, you can use it to retrieve content and files from various web servers.

Install wget

Launch command line application in Ubuntu that is terminal by pressing the Ctrl+Alt+T key combinations. Then enter the below command to install wget with sudo.

$ sudo apt-get install wget

When prompted for a password, enter sudo password.

Install wget on Ubuntu

Download file or webpage using wget

To download a file or a webpage, open the Terminal and enter the command in following syntax:

$ wget [URL]

Download files with wget

To save a single webpage, enter the command in the following syntax:

$ wget [URL]

Download a web page using wget

Download files with a different name

If you want to download and save the file with a different name than the name of the original remote file, use -O (upper-case O) as shown below. This is helpful especially when you are downloading a webpage that automatically get saved with the name “index.html”.

To download file with a different name, enter the command in the following syntax:

$ wget -O [filename] [URL]

Download files with a different name

Download files through FTP

To download a file from FTP server, type the command in the following syntax:

$ wget [ftp_link]

Download files through FTP

To download files from user authenticated FTP servers, use the below syntax:

$ wget -u [ftp_user]:[ftp_passwd] -O [ftp_URL]

Recursively download files

You can use recursive download feature to download everything under the specified directory whether a website or FTP site. To use recursive download feature, enter the command in below syntax:

$ wget –r [URL]

Recursively download files using wget

Download multiple files

You can use wget to download multiple files. Make a text file with a list of files URLs, then use the wget command in the following syntax to download that list.

$ wget –i [filename.txt]

For instance, I have the text file named “downloads.txt” in which there is a list of two URLs which I want to download using wget. You can see my text file content in the below image:

Download multiple files with wget

I will use the below command to download the file links contained in the text file:

$ wget –i download.txt

Using a file which contains urls as download list

You can see that it is downloading both links one by one.

Pause and Resume download

You can Press Ctrl + C to pause a download. To resume a paused download, go to the same directory where you were downloading the file previously and use –c option after wget as in below syntax:

$ wget -c filename.zip

wget: Pause and Resume download

Using the above command, you will notice that your download has resumed from where it was paused.

So in this article, we have discussed basic usage of two command line methods using which you can download a file. One thing to Note that if you do not specify a directory while downloading a file, the files will be downloaded in the current directory in which you are working.

How to Download a File on Ubuntu Linux using the Command Line