Linux: How to Download a File From a URL in Terminal

To download a file from a URL in the Linux terminal, the two most common tools are Wget and curl. For a simple download with the server's filename, use wget "URL". With curl, use curl -L -O "URL" so curl follows HTTP redirects and saves the remote filename instead of printing the file to the terminal.

Quick commands for downloading a URL

TaskCommand
Download with Wgetwget "https://example.com/archive.tar.gz"
Download with curlcurl -L -O "https://example.com/archive.tar.gz"
Choose a filename with Wgetwget -O archive.tar.gz "URL"
Choose a filename with curlcurl -L -o archive.tar.gz "URL"
Resume with Wgetwget -c "URL"
Resume with curlcurl -L -C - -o archive.tar.gz "URL"

Check whether Wget or curl is installed

Many Linux distributions include one or both tools already. Check before installing anything:

command -v wget
command -v curl

If a command prints a path such as /usr/bin/wget, it is available. If not, install the tool with your distribution's package manager:

# Ubuntu or Debian
sudo apt install wget curl

# Fedora
sudo dnf install wget curl

# Arch Linux
sudo pacman -S wget curl

# openSUSE
sudo zypper install wget curl

Download a file with Wget

Wget is convenient when the goal is simply to fetch files. Its basic syntax is wget [options] URL, as documented in the official GNU Wget manual.

wget "https://example.com/archive.tar.gz"

By default, Wget saves the download in the directory where you ran the command, using a filename derived from the URL.

Linux terminal running wget to download archive.tar.gz from a URL
A basic Wget download saves the file in the current terminal directory.

Save to another directory or filename

To keep the remote filename but place the file under Downloads, use Wget's directory-prefix option:

wget -P "$HOME/Downloads" "https://example.com/archive.tar.gz"

To explicitly choose the output filename, use uppercase -O:

wget -O "$HOME/Downloads/archive.tar.gz" "https://example.com/archive.tar.gz"

Be careful with -O when supplying several URLs: Wget treats it like one output stream, so multiple downloads can be written into the same output file. The GNU download-options reference explains this behavior.

Linux terminal using wget -O to save a URL download under the Downloads directory
The -O option gives the downloaded content an explicit local path and filename.

Resume an interrupted Wget download

If a previous download stopped partway through and the server supports resuming, run:

wget -c "https://example.com/large-file.iso"

Wget's -c option continues from an existing partial file when possible. It is meant for a download started by an earlier Wget run or another program, not merely for retrying a connection that fails during the current run.

Download multiple URLs from a text file

Create a plain-text file with one URL per line, for example urls.txt, then use:

wget -i urls.txt

The Wget input-file documentation confirms that -i reads URLs from a file.

Download a file with curl

curl writes response data to standard output unless you tell it to save to a file. The practical download form is:

curl -L -O "https://example.com/archive.tar.gz"

-L follows HTTP redirects, while uppercase -O saves the file using the name from the URL. These options are documented in the official curl man page.

Linux terminal running curl -L -O to save archive.tar.gz from a URL
With curl, -L follows redirects and -O saves the URL's filename.

Choose the curl output path

Use lowercase -o when you want to choose the local filename yourself:

curl -L -o "$HOME/Downloads/archive.tar.gz" "https://example.com/archive.tar.gz"

This is usually clearer than shell redirection because curl directly manages the output file.

Resume a curl download

For an interrupted download, -C - tells curl to determine the resume offset from the local file:

curl -L -C - -o archive.tar.gz "https://example.com/archive.tar.gz"

Resume support still depends on the protocol and server. Do not combine curl's --remove-on-error with -C; the current curl documentation marks those options as incompatible.

Linux terminal resuming a partial download with curl -L -C - and -o
The -C - option asks curl to resume from the existing partial file.

A few terminal download safety tips

  • Quote URLs when they contain characters such as &, ?, *, brackets, or braces so the shell does not interpret them.
  • Prefer HTTPS and do not routinely bypass certificate checks with curl -k or Wget --no-check-certificate.
  • Verify checksums when the publisher provides a SHA-256 or similar digest for large installers, ISO images, or archives.
  • Avoid putting passwords or long-lived secrets directly in URLs; command lines can be stored in shell history and may be visible to other processes or users.

For one-off downloads, Wget is often the shortest command. curl is especially useful when you also need redirect handling, custom headers, authentication, APIs, or other HTTP controls. For ordinary Linux terminal downloads, either tool is reliable when you use the correct output and resume options.

Leave a Comment

How to Record Speaker Output on Linux with Audacity

How to Record Speaker Output on Linux with Audacity

Capture Linux desktop audio in Audacity by routing its recording stream to your output device’s monitor source. Follow PulseAudio and PipeWire steps, export tips, and fixes for silent tracks.

How to Use Dropbox on Linux: Install and Sync Your Files

How to Use Dropbox on Linux: Install and Sync Your Files

Install Dropbox on Linux from the official package, sign in, sync a local folder, manage selective sync, and check status from the command line.

How to Install Inkscape on Linux: Ubuntu, Fedora, Arch, and More

How to Install Inkscape on Linux: Ubuntu, Fedora, Arch, and More

Install Inkscape from your Linux distribution’s repositories, the Ubuntu stable PPA, Snap, or Flathub, with current commands and notes for choosing a package source.

How to Find and Remove Duplicate Files on Linux With FSlint

How to Find and Remove Duplicate Files on Linux With FSlint

Use FSlint to scan selected Linux folders, review duplicate groups, and safely delete redundant files or learn when hard-link merging is appropriate.

How to Install SABnzbd on Linux and Configure It

How to Install SABnzbd on Linux and Configure It

Install SABnzbd on Ubuntu or Debian, or run it in Docker on another Linux host. Then open the web interface and configure your provider and download folders.

How to Install the Paper GTK Theme on Linux

How to Install the Paper GTK Theme on Linux

Install the Paper GTK theme from supported Linux repositories, enable it for GTK apps in GNOME Tweaks, and see what the legacy theme can and cannot change.

How to Install and Set Up Plex on OpenMediaVault with Compose

How to Install and Set Up Plex on OpenMediaVault with Compose

The old OpenMediaVault Plex plugin is archived. Set up Plex on OMV 8 with OMV-Extras, the Compose plugin, persistent storage, and Plex’s official container.

How to Clean and Speed Up Ubuntu Safely

How to Clean and Speed Up Ubuntu Safely

Clean and speed up Ubuntu with safe APT cleanup, storage checks, and startup controls that help free space and troubleshoot a sluggish desktop.

How to Install the Hiri Email Client on Linux

How to Install the Hiri Email Client on Linux

Install Hiri on Linux with its Snap package or official tarball, add a desktop launcher, and check supported accounts plus a warning about Hiri’s old Snap release.

How to Get System Specifications for a Linux PC

How to Get System Specifications for a Linux PC

Use Fastfetch and built-in Linux commands to check your distro, kernel, CPU, memory, graphics, storage, and connected devices, then save a clear report.