If you manage Linux servers, you regularly download files from the terminal, including release tarballs, ISO images, installation scripts, and backups stored on remote machines.
A simple download is usually enough, but sooner or later, a 3 GB ISO stops at 80% over a slow connection, or a download consumes bandwidth needed by production traffic. That’s when you need more control than simply restarting the download and hoping for the best.
GNU Wget is a free, non-interactive command-line downloader that supports HTTP, HTTPS, FTP, and FTPS. It can resume interrupted downloads, retry network failures, limit bandwidth usage, run in the background, read URLs from a file, and mirror entire websites for offline use. Because it doesn’t require interactive input, it works well in scripts, cron jobs, and SSH sessions.
The current stable release is Wget 1.25.0, released in November 2024, and most distributions ship a 1.2x version. However, one change matters if you’re using a recent Fedora release: the wget command may no longer refer to GNU Wget 1.x. Let’s look at what changed first.
Wget vs Wget2: Which One Your Distribution Ships
Before running the examples, check which version of Wget your distribution provides, because some options behave differently between the two versions.
Wget2 is the successor to GNU Wget, rewritten from scratch with support for HTTP/2 and parallel downloads. Starting with Fedora 40, the wget2-wget package replaces the traditional wget package, so running wget on Fedora launches Wget2.
According to the Fedora change proposal, Wget2 is largely a drop-in replacement, but it does not support FTP or WARC (Web ARChive) downloads.
Ubuntu, Debian, Rocky Linux, AlmaLinux, and RHEL generally provide classic GNU Wget 1.x through their wget packages, though the exact version depends on the distribution release.
Both versions use the same basic syntax:
wget [options] [URL]
To identify the version installed on your system, run:
wget --version | head -1
Output:
GNU Wget 1.25.0 built on linux-gnu.
If the output identifies GNU Wget2 instead, you’re using Wget2, and the FTP example later in this guide won’t work. The remaining examples are intended to work with both versions unless a specific difference is noted.
Install Wget on Linux
Most Linux server images include Wget, but minimal container and cloud images may not. If running wget --version returns a “command not found” error, install it using your distribution’s package manager.
On Ubuntu, Debian, and Linux Mint, refresh the package index before installing Wget:
sudo apt update sudo apt install -y wget
On Rocky Linux, AlmaLinux, and RHEL, install Wget using DNF:
sudo dnf install -y wget
On Fedora 40 and later, the same command installs the wget2-wget package, which provides the wget command through Wget2:
sudo dnf install -y wget
On Arch Linux, install Wget from the official repositories using Pacman:
sudo pacman -S wget
On openSUSE, use Zypper:
sudo zypper install wget
With Wget installed, let’s start with a basic download and build up to more advanced options.
1. Download a Single File with Wget
The simplest way to use Wget is to pass it a URL. It downloads the file into your current directory, using the filename specified by the URL. We’ll use the GNU Wget source tarball as an example throughout the first few sections:
wget https://ftp.gnu.org/gnu/wget/wget-1.25.0.tar.gz
Output:
--2026-10-26 10:15:16-- https://ftp.gnu.org/gnu/wget/wget-1.25.0.tar.gz Resolving ftp.gnu.org (ftp.gnu.org)... 209.51.188.20, 2001:470:142:3::b Connecting to ftp.gnu.org (ftp.gnu.org)|209.51.188.20|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 5381232 (5.1M) [application/x-gzip] Saving to: 'wget-1.25.0.tar.gz' wget-1.25.0.tar.gz 100%[===================>] 5.13M 3.21MB/s in 1.6s 2026-10-26 10:15:18 (3.21 MB/s) - 'wget-1.25.0.tar.gz' saved [5381232/5381232]
The 200 OK response indicates that the server successfully handled the HTTP request. The final saved [x/y] message confirms that Wget saved the expected number of bytes.
If you run the same command again, Wget normally preserves the existing file and saves the new download under a numbered filename, such as wget-1.25.0.tar.gz.1 or .2. This behavior is easy to overlook in scripts that download the same file every night.
2. Save a Download Under a Different Name with -O
Wget’s automatic .1 filename suffix can be inconvenient, especially in scripts. Use the uppercase -O option to specify the output filename. If that file already exists, Wget overwrites it:
wget -O wget-latest.tar.gz https://ftp.gnu.org/gnu/wget/wget-1.25.0.tar.gz
Keep the correct file extension when renaming a download. Saving a .tar.gz archive as wget.zip does not change its format, so unzip will not be able to extract it.
You can also use -O- to send downloaded content to standard output instead of saving it to a file. Combined with -q, which suppresses Wget’s status messages, this lets you inspect a script before running it:
wget -qO- https://get.example.com/install.sh | less
Reviewing an installation script before executing it can help you spot unexpected commands or potentially harmful changes to your server.
3. Download Files into a Specific Directory with -P
Renaming covers single files, but when you download several files into a project or a shared location, it’s simpler to tell wget where to put them. The -P option sets the directory prefix, and wget creates the directory if it doesn’t exist yet:
wget -P ~/downloads/gnu https://ftp.gnu.org/gnu/wget/wget-1.25.0.tar.gz
This keeps your current working directory clean, which matters when you run wget from a script whose working directory you don’t control, such as a cron job.
4. Download Multiple Files at Once with Wget
Wget accepts more than one URL in a single command and downloads them one after another. A common case is grabbing a tarball together with its GPG signature, so you can verify it right after:
wget https://ftp.gnu.org/gnu/wget/wget-1.25.0.tar.gz https://ftp.gnu.org/gnu/wget/wget-1.25.0.tar.gz.sig
Since both files come from the same server, wget reuses the open connection for the second file instead of connecting again, and you will see Reusing existing connection to ftp.gnu.org:443 in the output.
If you need a numbered series of files, you can let the shell generate the URLs with brace expansion. This is a Bash feature rather than a wget option, so the shell expands {1..5} into five separate URLs before wget runs. For example, to download the Linux 6.6.1 to 6.6.5 kernel tarballs:
wget https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.6.{1..5}.tar.xz
5. Download a List of URLs from a File with -i
Typing URLs works for two or three files, but for a longer list, or a list another script produces, it’s easier to keep the URLs in a text file and pass it with the -i option. Each URL goes on its own line.
Create the list with nano on Ubuntu and Debian:
nano download-linux.txt
On Rocky Linux, AlmaLinux, and RHEL, minimal installs ship with vi rather than nano, so use vi there:
vi download-linux.txt
Then add the URLs you want to download:
https://releases.ubuntu.com/26.04/ubuntu-26.04.1-live-server-amd64.iso https://download.rockylinux.org/pub/rocky/10/isos/x86_64/Rocky-10.1-x86_64-dvd1.iso https://cdimage.debian.org/debian-cd/current/amd64/iso-dvd/debian-13.1.0-amd64-DVD-1.iso
Save the file and exit the editor, then pass it to wget:
wget -i download-linux.txt
Since wget 1.25.0, -i - reads URLs from a pipe continuously until the pipe closes, instead of reading the list only once at startup. This means a script that produces URLs over time can feed wget as it goes.
.1 and .2 copies, share it with someone who’s still deleting duplicate ISOs by hand.6. Resume an Interrupted Download with -c
Large ISO files are especially prone to interruptions when an SSH session drops or the network connection fails. If you rerun the same Wget command without the appropriate option, Wget typically starts a new download and saves it under a numbered filename, leaving the partial file untouched.
The -c (continue) option tells Wget to resume the existing partial download by requesting the remaining bytes from the server:
wget -c https://releases.ubuntu.com/26.04/ubuntu-26.04.1-live-server-amd64.iso
When the server supports resuming, and the request succeeds, it typically responds with 206 Partial Content rather than 200 OK. The output indicates how much data remains to be downloaded:
HTTP request sent, awaiting response... 206 Partial Content Length: 3213064192 (3.0G), 2463109120 (2.3G) remaining [application/octet-stream]
If the server doesn’t support byte-range requests, Wget may need to restart the download. Including -c in commands for large files makes retries more convenient, but always check the output to confirm that the download actually resumed.
7. Retry Failed Downloads with –tries and –waitretry
Resuming a download manually is straightforward when you’re watching the terminal, but automated jobs need to handle temporary failures themselves.
GNU Wget retries failed downloads by default, up to 20 attempts, although some errors are treated as fatal unless you configure additional retry behavior.
To make a download more resilient to temporary network failures and overloaded mirrors, use:
wget -c --tries=10 --waitretry=30 --retry-connrefused --retry-on-http-error=503,429 https://releases.ubuntu.com/26.04/ubuntu-26.04.1-live-server-amd64.iso
Here’s what each option does:
-cresumes the existing partial file when a retry is needed, and the server supports it.--tries=10limits the number of download attempts.--waitretry=30increases the delay between retries, up to 30 seconds, giving a struggling server time to recover.--retry-connrefusedtreats connection-refused errors as temporary failures worth retrying.--retry-on-http-error=503,429retries when the server returns HTTP503 Service Unavailableor429 Too Many Requests, provided the installed Wget version supports this option.
Check the installed version’s documentation before using version-specific options, especially on Fedora systems that provide Wget2.
8. Limit Wget Download Speed with –limit-rate
Reliable downloads are useful, but a large transfer running at full speed can consume bandwidth needed by other services. The --limit-rate option caps Wget’s download rate. Use k for kilobytes per second or m for megabytes per second:
wget -c --limit-rate=2m https://releases.ubuntu.com/26.04/ubuntu-26.04.1-live-server-amd64.iso
Wget regulates the transfer rate over time, so the progress indicator may briefly show a higher speed before settling near the configured limit. For more details, see our guide on how to limit file download speed using Wget.
9. Run Wget in the Background with -b and Write a Log with -o
A rate-limited download of a 3 GB ISO can take a long time, and you may not want to keep an SSH session open to monitor it. The -b option starts Wget in the background, returning control of the terminal to you.
By default, Wget writes its output to wget-log in the current directory. Use the lowercase -o option to specify a different log filename:
wget -b -c --limit-rate=2m -o ubuntu-iso.log https://releases.ubuntu.com/26.04/ubuntu-26.04.1-live-server-amd64.iso
Output:
Continuing in background, pid 8999.
Without -o, Wget reports that output will be written to wget-log. Subsequent runs may create numbered log files, such as wget-log.1 and wget-log.2.
To monitor the download, follow the log with tail command:
tail -f ubuntu-iso.log
Example output:
5600K .......... .......... .......... .......... .......... 0% 2.01M 25m31s 5650K .......... .......... .......... .......... .......... 0% 1.98M 25m30s 5700K .......... .......... .......... .......... .......... 0% 2.02M 25m30s
These lines illustrate download progress, transfer speed, and estimated time remaining. Press Ctrl+C to stop following the log; the background download continues running.
Keep in mind that a background Wget process does not survive a server reboot. Combining -b with -c, as shown above, lets you resume an interrupted download by running the command again.
10. Check URLs Without Downloading Using –spider
Sometimes you need to check whether a file exists before a deployment script downloads it, or verify that a release URL still works. The --spider option lets Wget check a URL without saving the file locally.
wget –spider https://ftp.gnu.org/gnu/wget/wget-1.25.0.tar.gz
If the requested file does not exist, the output may include a message like this:
HTTP request sent, awaiting response... 404 Not Found Remote file does not exist -- broken link!!!
The exclamation marks are part of Wget’s own error message. Wget also returns a non-zero exit status when the check fails, allowing you to use it in shell scripts:
wget -q --spider https://ftp.gnu.org/gnu/wget/wget-1.25.0.tar.gz && echo "Release is available"
The message appears only if the URL check succeeds, making this a simple way to verify a download link before proceeding with the next step.
11. Mirror an Entire Website for Offline Use with –mirror
The --spider option checks links without saving files, while mirroring downloads pages and their resources for offline browsing. This is useful for keeping a local copy of internal documentation or archiving a small website before migrating it.
The --mirror option enables recursive downloading and timestamping, allowing Wget to retrieve files at any depth and update files that have changed since the previous run. Combine it with a few additional options to make the downloaded copy easier to browse offline:
wget --mirror --page-requisites --adjust-extension --convert-links --no-parent --wait=1 --random-wait https://docs.tecmint.lan/handbook/
Here’s what each option does:
--mirrorenables recursive downloading, timestamping, and unlimited recursion depth, along with options to preserve FTP directory listings.--page-requisitesdownloads resources such as CSS, JavaScript, and images needed to display each page correctly.--adjust-extensionadjusts downloaded HTML filenames so pages can be opened locally with the appropriate extension.--convert-linksrewrites links in downloaded pages to point to local copies where possible.--no-parentprevents Wget from following links to parent directories above/handbook/.--wait=1pauses for at least one second between retrievals, while--random-waitvaries the delay to reduce the frequency of requests.<
If the site loads resources from a separate domain, such as a CDN, you may need --span-hosts and --domains to include the additional hosts:
wget --mirror --page-requisites --adjust-extension --convert-links --no-parent --span-hosts --domains=docs.tecmint.lan,cdn.tecmint.lan --wait=1 --random-wait https://docs.tecmint.lan/handbook/
Use --restrict-file-names=windows only when you need filenames compatible with Windows, since it changes characters that Windows does not allow in filenames.
Only mirror websites you own or have permission to copy, and respect their robots.txt rules, which Wget follows by default during recursive downloads.
12. Download Password-Protected Files Without Exposing the Password
Internal documentation and private file servers often require authentication. Wget supports HTTP authentication with --user and FTP authentication with --ftp-user. However, passing a password directly with --password=secret can expose it through shell history or process listings.
A safer option for interactive downloads is --ask-password, which prompts you to enter the password:
wget --user=tecmint --ask-password https://files.tecmint.lan/backups/db-2026-10-25.sql.gz
For automated scripts and cron jobs, where interactive prompts aren’t practical, you can store credentials in a `~/.netrc` file that Wget can read automatically.
On Ubuntu and Debian, create the file with Nano:
nano ~/.netrc
On Rocky Linux, AlmaLinux, and RHEL, use Vi if Nano isn’t installed:
vi ~/.netrc
Add the following configuration, replacing the example credentials with your own:
# ~/.netrc machine files.tecmint.lan login tecmint password YourStrongPassword
Here’s what each entry means:
machinespecifies the hostname to which the credentials apply.loginspecifies the username for that host.passwordspecifies the password, stored in plain text, making file permissions especially important.
Save the file and restrict its permissions so only your user can read and write it:
chmod 600 ~/.netrc
You can now download the file without placing credentials in the command:
wget https://files.tecmint.lan/backups/db-2026-10-25.sql.gz
For security, use HTTPS whenever possible, protect the .netrc file, and avoid committing it to version control. Although this approach keeps passwords out of command-line arguments, the credentials remain stored in plain text.
FTP downloads can also use credentials from .netrc, but classic GNU Wget and Wget2 differ in their FTP support. On Fedora 40 and later, where the wget command uses Wget2, use an FTP-capable client such as curl or lftp if FTP support is unavailable.
Pro Tips: Certificates, Defaults, and Safer Wget Downloads
A few additional habits can make Wget safer and easier to use, especially when downloading over HTTPS or running automated scripts.
Avoid using --no-check-certificate as a routine fix for certificate errors. This option disables certificate verification, making it harder to confirm that you’re connecting to the intended server. Public websites such as kernel.org should not normally require it. If Wget reports that a certificate is expired or not yet valid, check the system clock with `date` before investigating other causes.
For an internal server that uses a certificate issued by your own certificate authority (CA), configure Wget to trust that CA instead of disabling verification:
wget --ca-certificate=/etc/pki/tls/certs/tecmint-ca.crt https://192.168.122.248/repo/app.tar.gz
You can also set default options in ~/.wgetrc, which GNU Wget reads each time it runs. This avoids repeating the same flags in every command.
On Ubuntu and Debian, create the file with Nano:
nano ~/.wgetrc
On Rocky Linux, AlmaLinux, and RHEL, use Vi if Nano isn’t installed:
vi ~/.wgetrc
Add the following configuration:
# ~/.wgetrc continue = on tries = 10 waitretry = 30 https_only = on
Here’s what each setting does:
continue = onenables download resuming by default, equivalent to using-c.tries = 10** sets the default number of download attempts to 10.waitretry = 30sets the maximum wait between retries to 30 seconds.https_only = onrestricts recursive downloads to HTTPS URLs, preventing Wget from following ordinary HTTP links during mirroring.
Save the file and exit the editor. Command-line options generally override the corresponding configuration defaults, so you can disable a default for an individual run using the appropriate option, such as --no-continue.
Keep in mind that configuration-file names and supported options can differ between GNU Wget and Wget2. If you’re using Fedora’s Wget2-based wget command, check its documentation to confirm which configuration file it reads and which settings it supports.
Conclusion
Wget can do much more than download a single file. You can rename and organize downloads, resume interrupted transfers, retry failed requests, limit bandwidth, run downloads in the background, mirror websites for offline use, and handle authentication without exposing passwords on the command line.
You also know why checking your installed version matters, especially on Fedora, where Wget2 differs from classic GNU Wget in its FTP support. For details on available options, consult man wget or wget --help.
To build your skills with other essential Linux tools, including tar, curl, grep, and tail, check out our 100+ Essential Linux Commands course for practical examples.
If you want to turn downloads into scheduled jobs with error handling, our Bash Scripting for Beginners course shows you how to build reliable scripts around commands like these.
How do you use Wget in your own setup? Do you still rely on it for scripted downloads, or have you switched to curl or Wget2?
Share your .wgetrc defaults in the comments, or post the exact error output if you’re having trouble with a download.
Hi,
I need help regarding below, when T try to download website using command
wget --mirror, it is going to ReadLine loop and coming out to complete request, can any one suggest on the same please.private void downLoadReport() { Runtime rt = Runtime.getRuntime(); try { System.out.println("InsideTRY"); Process p = rt.exec(wgetDir + "wget --mirror http://alex.smola.org/drafts/thebook.pdf"); // return result == 0; // Process p = Runtime.getRuntime().exec("wget --mirror // http://askubuntu.com"); System.out.println("Process " + p); BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream())); String line; while ((line = reader.readLine()) != null) { // System.out.println(lineNumber + "\n"); } System.out.println(line + "\n"); System.out.println("Download process is success"); System.out.println("Wget --mirror has been successfully executed...."); } catch (IOException ioe) { System.out.println(ioe); } /* * catch (InterruptedException e) { // TODO Auto-generated catch * block e.printStackTrace(); } */ }everything is ok, but how to find particular software link (google chrome, team viewer etc.)
Great post! Have nice day ! :)
We are facing slowness when we are sending traffic using wget in linux machines through TCL .
Traffic passing gets struck in the middle when the file size is more than 100MB.
Hence we are unable to meassure the bandwidth during download.
Please suggest any way to address this issue.
You made my day. I tried without the ftp:// and failed one time after the other.
It’s due to permission of sending file…change it to 777 and try without ftp:// (it definitely works)
Hi…
I want to make a script to check a website and download the latest available version of a deb file and install it.
The problem I have is that on the website, each time the version changes, so the file name is changed, so I can not know the exact name to give the order to wget.
I wonder if there is any way to include wildcards in wget, or similar option.
As an example, suppose you want to download each x time the latest “Dukto” in 64 bits.
Their website is:
http://download.opensuse.org/repositories/home:/colomboem/xUbuntu_12.04/amd64/dukto_6.0-1_amd64.deb
How i can tell wget to look in that directory and download the dukto*.deb?
Thanks in advance.
what does is mean by “downloads file recursively” ??
That means it will go through all the links on the website. So, for example, if you have a website with links to more websites then it will download each of those and any other links that are in that website. You can set the number of layers, etc (reference http://www.gnu.org/software/wget/manual/html_node/Recursive-Retrieval-Options.html ). This is actually how google works but for the whole internet, it goes through ever link on every website to every other one. Also, if you use some more commands you can actually download a whole site and make it suitable for local browsing so if you have a multipage site that you use often, you could set it recursive and then open it up even without an internet connection. I hope that makes sense(the tl;dr version is that it follows every link on that website to more links and more files in a ‘tree’)
Also, sorry for the late reply(by a few years or so)