Knowledgebase

Find frequently asked questions and setup guides by searching or by browsing the categories.

Download a File

wget https://example.com/files/app-1.4.2.tar.gz

The file is saved under its own name in the current folder, with a progress bar while it downloads. If wget is missing, install it: sudo apt install wget on Debian and Ubuntu, sudo dnf install wget on AlmaLinux and Rocky Linux. Debian, Ubuntu, AlmaLinux, and Rocky Linux ship GNU Wget 1.x. Fedora installs Wget2 under the name wget; it accepts the common options below but has no FTP or WARC support. wget --version shows which one you have.

Common Options

OptionWhat it does
-O nameSaves under another name
-P dirSaves into a folder
-cResumes a partial download
-qQuiet: no output
-bRuns in the background
--limit-rate=2mCaps speed at 2 MB/s
-i list.txtDownloads every URL in a file
--tries=5Tries up to five times
--timeout=30Gives up on a stalled connection

Save Under Another Name

wget -O app.tar.gz https://example.com/files/app-1.4.2.tar.gz
wget -P /srv/downloads https://example.com/files/app-1.4.2.tar.gz

Note the capital O: lowercase -o writes wget's own messages to a log file instead.

Resume and Retry

wget -c --tries=5 --timeout=30 https://example.com/files/large.iso

If a large download stops, run the same command with -c in the same folder: wget continues from where the file ends, provided the server supports partial downloads; otherwise it starts again from the beginning. The default is 20 tries, and errors such as 404 or a refused connection are not retried. If the file on the server has changed since the first attempt, delete the partial copy instead of resuming.

Limit the Rate and Run in the Background

wget -b --limit-rate=2m https://example.com/files/large.iso
tail -f wget-log

A rate limit keeps a big download from slowing down the sites on the same server. With -b, wget moves to the background at once and, unless you set a log file with -o, writes its progress to wget-log in the current folder. For other long commands, see the nohup command.

Download a List of Files

wget -c -i urls.txt --wait=1

Put one URL per line in urls.txt. --wait=1 pauses one second between files.

Mirror Your Own Site

Mirror only sites you own or have permission to copy, and keep the load low:

wget --mirror --convert-links --adjust-extension --page-requisites \
  --no-parent --wait=1 --limit-rate=500k https://example.com/

This copies the pages and the files they need into a folder named after the domain, with links rewritten to work offline. --mirror turns on unlimited recursion and timestamping, and wget follows the site's robots.txt while it crawls. It gives you the site as visitors see it, not its database or source code, so it does not replace a backup.

Verify Before You Use a File

Compare the file with the checksum the publisher lists before you unpack or run anything:

sha256sum app-1.4.2.tar.gz
sha256sum -c app-1.4.2.tar.gz.sha256

The second form reads the expected value from a checksum file and prints OK or FAILED. If the project publishes a signature, check that too. Then unpack it; see how to extract tar.gz files.

Never Pipe a Download into a Shell

A line such as wget -qO- URL | sh runs whatever the server sends, with your rights, before anyone has read it. Download the script to a file, read it, verify it, and then run it.

Errors and wget vs curl

  • 404 Not Found or 403 Forbidden: the URL is wrong or the file is not public.
  • Certificate errors: update ca-certificates and check the server clock. Turning off certificate checks is not the fix.

wget is built for downloading files and folders; curl is better at talking to APIs. See how to download a file with curl.

Was this answer helpful?
Loading...