Linux

How to download files on Linux with Curl

Curl is one of the most used Linux utilities ever. It’s built-in so many GUI tools and used on pretty much everything. As a result, it is very reliable and one of the best tools users can use to download files.

download files on Linux with Curl

In this guide, we’ll show you how the Curl program works and how to use it to download files with it. We’ll even go over a neat GUI Curl app!

Need to use Curl on Windows 10? Check out this guide.

Installing Curl

Although Curl is arguably one of the most used programs on all of Linux, it doesn’t always come pre-installed. As a result, we must walk you through how to install Curl before demonstrating how it works.

To install Curl on your Linux PC, open up a terminal window by pressing Ctrl + Alt + T . After that, follow the installation instructions outlined below that corresponds with the operating system you currently use.

Ubuntu

On Ubuntu, install Curl with the Apt command.

sudo apt install curl

Debian

On Debian, get Curl working with Apt-get.

sudo apt-get install curl

Arch Linux

Those on Arch Linux can install Curl with Pacman.

sudo pacman -S curl

Fedora

If you’re on Fedora, you can install Curl with Dnf.

sudo dnf install curl

OpenSUSE

On OpenSUSE, install Curl with the Zypper command.

sudo zypper install curl

Download with Curl – command-line 

If you’re new to Curl, start by opening up the terminal. You can open up a terminal window on the Linux desktop by pressing the Ctrl + Alt + T keyboard combination. Alternatively, search for “Terminal” in the app menu.

With the terminal window open, use the man curl command to view the Curl manual. Please read it, and familiarize yourself with the app. After that, follow along with the sections below to learn how to download files with Curl in the terminal.

Downloading a single file

Downloading a single file with Curl is very straightforward. To start, you must specify the URL of the file. For example, to download a Ubuntu 20.04 LTS ISO, you’d specify the URL like so.

curl https://mirror.math.princeton.edu/pub/ubuntu-iso/20.04/ubuntu-20.04.2.0-desktop-amd64.iso

After specifying the remote URL of the file you wish to download, you must select a download location. To set the download location, add a symbol, followed by the path where the file should go.

For example, to tell your Ubuntu 20.04 LTS ISO file to download to the “Downloads” directory, you’d add in > ~/Downloads/ubuntu-20.04.2.0-desktop-amd64.iso.

curl https://mirror.math.princeton.edu/pub/ubuntu-iso/20.04/ubuntu-20.04.2.0-desktop-amd64.iso > ~/Downloads/ubuntu-20.04.2.0-desktop-amd64.iso

Once the command has the remote file’s URL and where to save it, press the Enter key to execute the download. Soon after, you’ll see download progress, as well as your file downloading. When it is complete, open up the Linux file manager to access your file.

Downloading multiple files from a list

It is possible to download multiple files from a list in Curl just like Wget. To do it, start by creating your list. First, use the touch command to create a blank text file with the name “curl_downloads.txt.”

touch ~/curl_downloads.txt

Next, open up the “curl_downloads.txt” text file (located in your Home folder) using your favorite text editor. After that, paste in links to each file you wish to download. 

For example, to download an Ubuntu ISO, a Fedora ISO, and a Debian ISO, my “curl_downloads.txt” list should have the following code.

https://mirror.math.princeton.edu/pub/ubuntu-iso/20.04/ubuntu-20.04.2.0-desktop-amd64.iso

https://download.fedoraproject.org/pub/fedora/linux/releases/33/Workstation/x86_64/iso/Fedora-Workstation-Live-x86_64-33-1.2.iso

https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-10.9.0-amd64-netinst.iso

Save the edits to your “curl_downloads.txt” file using your text editor’s save function. Then, feed it into the Curl command to download everything on the list. Please note that we’re using xargs in combination with curl to make it possible to download multiple files.

xargs -n 1 curl -O < ~/curl_downloads.txt

Press the Enter key to begin the download process. Please understand that while using the xargs command to download multiple files, specifying a download location isn’t possible. Your downloads will appear in the Home directory (/home/USERNAME/).

Downloading with Curl – GUI

If you like the idea of Curl but would prefer a GUI to download files, you can use the Curl GUI application. It is a beta app from way back in 2007, but it still works on modern Linux OSes and adds a friendly GUI to Curl.

To start, you must install the program. The program is a Perl script, and it requires the “perl-tk” package to run. To install it, open up a terminal window and enter the command below that corresponds with your OS.

Ubuntu

sudo apt install perl-tk

Debian

sudo apt-get install perl-tk

Arch Linux

sudo pacman -S perl-tk

Fedora

sudo dnf install perl-Tk

OpenSUSE

sudo zypper install perl-Tk

Next, create a new directory in the /opt/ folder using mkdir.

sudo mkdir -p /opt/curl-gui/

Use the CD command to move into the new folder. Then use wget to download the script file.

cd /opt/curl-gui/
wget https://archive.org/download/curl-gui/curl-gui.pl

Then, download the shortcut file and mark it executable. 

cd /usr/share/applications/
wget https://archive.org/download/curl-gui_202104/curl-gui.desktop
sudo chmod +x curl-gui.desktop

Once the app is installed, search for “cURL GUI” in your app menu and click on it to launch the app. Then, inside the app, locate the text box at the top and paste your download link into it.

After pasting your download link, find “Output file” and check the box. Then, write in the name of the output file. For example, if you’re downloading an Ubuntu ISO, add “/home/USERNAME/Downloads/ubuntu-20.04.2.0-desktop-amd64.iso” after “Output.”

Click “START curl” to start your download. When the download is complete, close the app and open up the Linux file manager to access your downloaded file.

Похожие статьи

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *

Кнопка «Наверх»