How to Use the wget Command in Linux to Download Files from the Web

When working on a headless Linux server without a graphical desktop interface, you do not have access to a web browser like Chrome or Firefox to click a “Download” button. If you need to pull an installation script, a compressed software archive, or a dataset from the internet directly to your server, you must use the command line. The standard, robust utility for this task in the Linux ecosystem is the wget command.

Why Use the wget Command?

The wget (World Wide Web Get) command is a non-interactive network downloader. It supports HTTP, HTTPS, and FTP protocols. Because it is non-interactive, it is perfect for automated bash scripts, cron jobs, and unattended software installations. Furthermore, wget is incredibly resilient; if a large download is interrupted by a network drop, it has the ability to resume the download exactly where it left off.

Step 1: Perform a Basic Download

The simplest way to use the tool is to provide it with a direct URL.

  1. Open your Linux terminal.
  2. Navigate to the directory where you want the file to be saved.
  3. Type wget followed by the URL:
wget https://example.com/software-package-1.0.tar.gz

The terminal will display a progress bar, the download speed, and the estimated time remaining. The file will be saved in your current directory using its original filename (software-package-1.0.tar.gz).

Step 2: Save the File with a Different Name

Sometimes URLs are messy or dynamically generated, resulting in downloaded files having confusing names like download?id=12345. You can force wget to save the file under a clean, specific name.

  1. Use the -O (capital O for Output document) flag, followed by your desired filename, followed by the URL:
wget -O clean_package.tar.gz https://example.com/download?id=12345

The file will now be saved locally as clean_package.tar.gz.

Step 3: Resume an Interrupted Download

If you are downloading a massive 5GB ISO file and your SSH connection drops or the server reboots at 90%, you do not have to start over from the beginning.

  1. Navigate back to the directory containing the partially downloaded file.
  2. Run the command again, but add the -c (continue) flag:
wget -c https://example.com/massive-os-image.iso

wget will detect the existing file fragment, calculate the offset, and resume the download from 90%.

Step 4: Download Files Silently

If you are writing an automated deployment script, the standard progress bar output can clutter your log files.

  1. Use the -q (quiet) flag to suppress all output:
wget -q https://example.com/setup.sh

The command will execute silently, returning to the prompt only when the file is fully downloaded.

By mastering the wget command, Linux administrators can efficiently fetch external resources, automate software deployments, and handle large file transfers directly from the terminal.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.