Want to download files to your Linux PC from the command-line but don’t know how to do it? We can help! Follow along as we go over ways you can use the Linux terminal to download files!
Linux download from URL – Wget
The number one way to download files from the Linux terminal is with the Wget downloader tool. It is robust, has tons of useful features, and can even be configured to download multiple files at once via its download list feature.
The Wget downloader tool comes standard on a wide variety of Linux operating systems. Most users will be able to access Wget without the need to install it using the package manager. However, on some Linux OSes, Wget is not installed. For this reason, we must demonstrate how to install it.
To start installing the Wget downloader tool on your Linux PC, open up a terminal window. You can open up a terminal window by pressing Ctrl + Alt + T on most Linux desktops. Once it is open, follow the instructions below to get Wget.
sudo apt install wget
sudo apt-get install wget
sudo pacman -S wget
sudo dnf install wget
sudo zypper install wget
After installing the Wget tool, execute the wget –help command. This command will help you familiarize yourself with the program.
Basic downloads with Wget
If you want to download a file with Wget and don’t care about any of the advanced features and options outlined in the –help section, you’ll be happy to know that you can download any file from a URL on your Linux PC with the following command.
For example, to download the latest release of Debian Linux from Debian.org, you’d execute:
Any basic download through Wget is as simple as wget followed by a URL. Keep in mind that the Wget tool will download your file to the folder your terminal is in. For example, if your terminal session is accessing the “Documents” folder, the Wget download command will download to the “Documents” folder.
Wget download list
If you’d like to download multiple files in Wget with a single command, you’ll need first to create a download list. Using the touch command, make a new download list.
Next, open up the “download-list” file in the Nano text editor for editing purposes.
Paste all of the URLs you wish Wget to download to your PC in the download list. For example, if you’d like to download a series of PDF files, your “download-list” file will look like this:
http://example.com/a.pdf http://example.com/b.pdf http://example.com/c.pdf http://example.com/d.pdf http://example.com/e.pdf
After adding the URLs to your “download-list” file in the Nano text editor, press the Ctrl + O button to save it. Then, press Ctrl + X to close the editor. Once it is closed, execute the wget -i download-list command below.
wget -i download-list
Customize download location
If you’d like to customize where to save your Wget download, you will need to use the -O command-line switch that allows users to specify where Wget will place a file.
For example, to download the latest Debian ISO file to the “Downloads” directory, you’d execute the command below.
wget https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-10.7.0-amd64-netinst.iso -O ~/Downloads/debian-10.7.0-amd64-netinst.iso
Linux download from URL – Curl
If Wget isn’t your cup of tea, another way to download files from the command-line on Linux is with the Curl app. Curl is an impressive, useful program, and it has been around for a very long time.
Curl comes standard on some Linux operating systems, but not all. Since not every Linux OS installs it by default for users, we must demonstrate how to set up Curl. To start the installation, open up a terminal window on the Linux desktop.
Once the terminal window is open on the Linux desktop, follow along with the command-line installation instructions for Curl that corresponds with the Linux OS you currently use.
sudo apt install curl
sudo apt-get install curl
sudo pacman -S curl
sudo dnf install curl
sudo zypper install curl
With the Curl app installed, execute the curl –help command in a terminal to view Curl’s help page. Study the help page to get a feel for the app.
Basic downloads with Curl
Curl is excellent for no-frills downloads in the terminal, especially if you’re not worried about various download options and want to save a file to your computer.
To start a download using the Curl command on your Linux PC, find the URL of a file you wish to download. Then, add it to the curl command below. In this example, we will download the latest Debian ISO.
curl https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-10.7.0-amd64-netinst.iso > debian-10.7.0-amd64-netinst.iso
After executing the command above, you will see a progress bar appear in the terminal. When the progress bar goes away, the file is done downloading.
Curl Download list
Like Wget, the Curl app supports download lists. Here’s how to use a download list with Curl.
First, start by creating the download-list file with the touch command below.
After creating the download-list file, open it for editing in Nano.
nano -w download-list
Paste the URLs you wish to download into the download-list file. For example, if you want to download various MP4 files, you’d add the following URLs.
Save the edits to the download-list file by pressing Ctrl + O on the keyboard. Exit with Ctrl + X. After that, use the command below to have Curl download from the list.
xargs -n 1 curl -O < download-list
Customize download location
If you’d like to customize the file’s download location with Curl, you will need to add a download path to the command. To customize the download location, follow the example below.
curl HTTP://MY_DOWNLOADING_FILE.com/FILE.FILENAME > /home/USERNAME/my/custom/download/location/FILE.FILENAME