How to Download Files from URL in Linux Command Line

Development

Downloading files from a URL using the Linux command line might sound like geeky wizardry, but trust me—it’s easier than making toast. If you’ve got five minutes and a keyboard, you’re good to go!

This guide will walk you through the magical world of downloading files directly from web links using the command line. Whether you’re a newbie or just looking to download faster, these tools are handy, powerful, and surprisingly fun to use.

Why Use the Command Line?

The terminal is fast. No need to open a browser. No clicking buttons. Just type, hit Enter, and boom—your file’s on your system.

Also, the command line is automation-friendly. Want to download ten files? You can do it in a single command. That’s some serious superpower.

The Champions of Downloading: Meet curl and wget

These two commands are the heroes of our story.

  • wget — Simple and powerful. Great for downloading single files or entire websites.
  • curl — More flexible and ideal for scripting. Can handle a ton of different protocols.

How to Use wget

wget is often pre-installed in many Linux distros. Check if it’s available:

wget --version

If that works, you’re ready. If not, install it with:

sudo apt install wget

Or on Red Hat/Fedora based systems:

sudo dnf install wget

To download a file, just type:

wget https://example.com/file.zip

That’s it! The file lands in your current folder.

terminal wget download file linux

More Fun with wget

Want to save the file with a different name?

wget -O customname.zip https://example.com/file.zip

Need to retry automatically if the network flakes out?

wget --tries=10 https://example.com/file.zip

Downloading multiple files from a list?

wget -i files.txt

Where files.txt contains URLs—one per line. Cool, right?

How to Use curl

curl is another download ninja. It often comes preinstalled too.

Check if it’s there:

curl --version

If not, install it with:

sudo apt install curl

Or:

sudo dnf install curl

To download a file using curl:

curl -O https://example.com/file.zip

The -O (uppercase o) tells curl: “Save with the original filename.”

More Curl-y Tricks

Save with a custom name?

curl -o newname.zip https://example.com/file.zip

Download multiple files?


curl -O https://example.com/file1.zip \
     -O https://example.com/file2.zip

Need to follow redirects?

curl -L -O https://short.url/to/file.zip

Some websites redirect you. The -L flag tells curl to chase them down.

How to Choose Between wget and curl?

Both are awesome. Here’s a quick cheat sheet:

  • Use wget for simple downloads, especially big files.
  • Use curl when scripting, APIs, or authentication is involved.

curl wget linux commandline terminal

Downloading from Password-Protected URLs

Sometimes URLs ask, “Who are you?” Let’s teach your command line to say “Hi, I have a password.”

With wget:

wget --user=username --password=secret https://example.com/protected.zip

With curl:

curl -u username:secret -O https://example.com/protected.zip

Careful! Your password sits right there in the terminal. If others are watching, use secrets wisely.

Working Inside Scripts

Both wget and curl are super scriptable. That means you can do stuff like this:


#!/bin/bash
FILE_URL="https://example.com/file.zip"
wget "$FILE_URL"
echo "File downloaded!"

Or the curl version:


#!/bin/bash
FILE_URL="https://example.com/file.zip"
curl -O "$FILE_URL"
echo "It’s done!"

Put that in a file called get_file.sh, make it executable, and run. You’ve just automated a download 👍

Download in the Background

If you want to launch a big file download and carry on with life, this is your move:

wget -b https://example.com/hugefile.iso

That’ll keep it downloading even if you close the terminal (use screen/tmux to manage even better).

How to Check Progress

By default, both tools show progress bars.

  • wget shows a horizontal bar with estimates.
  • curl shows a simple dashboard with percentage, speed, and ETA.

Want to hide download output? Use:

wget -q URL
curl -sO URL

Using Proxy Servers

Behind a corporate proxy? Here’s how to sneak those downloads through:

export http_proxy=http://proxy.example.com:8080
wget URL

Same story for curl:

curl -x http://proxy.example.com:8080 -O URL

Resuming Broken Downloads

Did your connection drop? We got you.

With wget:

wget -c https://example.com/hugefile.iso

The -c says, “Hey, keep downloading from where you left off.”

With curl:

curl -C - -O https://example.com/hugefile.iso

That’s -C – (dash dash). It tells curl to resume too.

Bonus: Other Cool Tools

Okay, we’ve covered wget and curl. But Linux is full of bonus treats:

  • aria2 — A super-fast download manager for advanced users.
  • axel — Multi-threaded downloader that speeds things up.
  • youtube-dl — Yep, it downloads videos from YouTube and more.

aria2 curl wget axel linux tools

Summary: Quick Tips

  • Use wget for simple downloads and full sites.
  • Use curl for flexibility and scripting.
  • Add -O to save files with original names.
  • Use -c (wget) or -C – (curl) to resume downloads.
  • Use -L with curl to handle redirects.

And That’s a Wrap!

At this point, you’re ready to download anything the internet can throw at you—right from your terminal. No tabs, no nonsense. Just clean, powerful command-line magic.

Go forth and download, terminal hero 🎉