0% found this document useful (0 votes)
2 views7 pages

Commands

This document is a guide on using the wget command in Linux, detailing its installation and providing 12 practical examples for various download scenarios. It covers downloading single and multiple files, saving files under different names, limiting download speeds, and retrieving entire websites. The guide aims to equip users with the knowledge to effectively utilize wget for file downloads from the web.

Uploaded by

brushdstrokes25
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views7 pages

Commands

This document is a guide on using the wget command in Linux, detailing its installation and providing 12 practical examples for various download scenarios. It covers downloading single and multiple files, saving files under different names, limiting download speeds, and retrieving entire websites. The guide aims to equip users with the knowledge to effectively utilize wget for file downloads from the web.

Uploaded by

brushdstrokes25
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Reading package lists...

Done
Building dependency tree... Done
Reading state information... Done
5 packages can be upgraded. Run 'apt list --upgradable' to see them.
~$
Display all 922 possibilities? (y or n)
!
./
2to3
2to3-2.7
2to3-3.12
:
[
[[
]]
aarch64-linux-android-clang
aarch64-linux-android-clang++
aarch64-linux-android-cpp
aarch64-linux-android-g++
aarch64-linux-android-gcc
add-trusted-certificate
addpart
alias
am
amdgpu-arch
analyze-build
apt
apt-cache
apt-config
apt-get
apt-key
apt-mark
aria_chk
aria_dump_log
aria_ftdump
aria_pack
aria_read_log
arp
awk
b2sum
base32
base64
basename
basenc
bash
bg
bind
blkpr
blockdev
break
brotli
bugpoint
builtin
bunzip2
bzcat
bzcmp
bzdiff
bzgrep
bzip2
bzip2recover
bzless
bzmore
c++
cal
caller
captest
case
cat
cc
cd
chcon
chcpu
chgrp
chmod
choom
chown
chroot
chrt
chsh
cksum
clang
clang++
clang++-20
clang-20
clang-apply-replacements
clang-change-namespace
clang-check
clang-cl
clang-cpp
clang-doc
clang-extdef-mapping
clang-format
clang-include-cleaner
clang-include-fixer
clang-installapi
clang-linker-wrapper
clang-move
clang-nvlink-wrapper
clang-offload-bundler
clang-offload-packager
clang-query
clang-refactor
clang-reorder-fields
clang-repl
clang-scan-deps
clang-sycl-linker
clang-tblgen
clang-tidy
clangd
clear
cmatrix
cmd
cmp
col
colcrt
colrm
keyboard_arrow_down
Categories
search
VPS
Apr 25, 2025

Domantas G.

5min Read

What is the wget command and how to use it (12 examples included)
This guide teaches you how to use the wget command on Linux. It provides 12 examples of
wget commands in action to help you use them. Once you’re done, you’ll know all about wget
and how to use it to get files from the web.
What is the wget command?
How to install wget?
Wget command examples
Using wget command to download single files
Using wget command to download multiple files
Using wget command to get files under different names
Using wget command to save files in specified directory
Using wget command to limit download speed
Using wget command to set retry attempts
Using wget command to download in background
Using wget command to download via FTP
Using wget command to continue interrupted downloads
Using wget command to retrieve whole websites
Using wget command to locate broken links
Using wget command to download numbered files
Wget command FAQ
What is the wget command used for?
How do I run wget?
How do I download files using wget?
What is the wget command?
Wget is a command-line tool that makes it possible to download files from the internet directly to
your active directory. It operates in the background, allowing tasks to continue even if you’re
offline. The name is a combination of World Wide Web and the word get. It supports downloads
via FTP, SFTP, HTTP, and HTTPS.

Wget is created in portable C and is usable on any Unix system. It’s also possible to implement
on Mac OS X, Microsoft Windows, AmigaOS, and other popular platforms.

How to install wget?


For this wget command demonstration, we’ll be using Ubuntu 22.04. But the syntax will work on
any other Linux distribution too.

Firstly, access your server via SSH:

ssh user@your_server_ip -port


To install wget on Ubuntu 22.04, execute the following command:

sudo apt-get install wget


To install wget on CentOS 9 Sream or its previous distros, use:

sudo yum install wget


Once the setup finishes, you’ll be ready to use it. Also, the knowledge of basic SSH commands
can make things easier.
Wget command examples
To get you started, we’ll provide 12 wget command examples that you can use for everyday
tasks. Keep in mind that you may also call this function from scripts and cron jobs!

Using wget command to download single files


One of the most basic wget command examples is downloading a single file and storing it in
your current working directory. For example, you may get the latest version of WordPress by
using the following:

wget https://wordpress.org/latest.zip
Here is the output that you will see:

--2018-02-23 12:53:10-- https://wordpress.org/latest.zip


Resolving wordpress.org (wordpress.org)... 198.143.164.252
Connecting to wordpress.org (wordpress.org)|198.143.164.252|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 9332728 (8,9M) [application/zip]
Saving to: 'latest.zip'

latest.zip 100%[===================>] 8,90M 6,88MB/s in 1,3s

2018-02-23 12:53:14 (6,88 MB/s) - 'latest.zip' saved [9332728/9332728]


In this example, a file named latest.zip will be downloaded in the current working directory.
You’ll also see extra information, such as the download progress, speed, size, time, and date.

Using wget command to download multiple files


We can take wget usage one step further and download multiple files at once. To do that, we
will need to create a text document and place the download URLs there. In this example, we will
retrieve the latest versions of WordPress, Joomla, and Drupal by using wget. Enter the
following:

nano example.txt
This will create an example.txt file and open a text editor interface. Paste these links there:

https://wordpress.org/latest.zip

https://downloads.joomla.org/cms/joomla3/3-8-5/Joomla_3-8-5-Stable-Full_Package.zip

https://ftp.drupal.org/files/projects/drupal-8.4.5.zip
Once done, you may use -i to get all the files stored in your example text file:

wget -i example.txt
Wait for the process to finish, and you’ll have the installations of the three most popular content
management systems.

Using wget command to get files under different names


In this wget example, we will save a file using a different name with the help of the -O option:

wget -O wordpress-install.zip https://wordpress.org/latest.zip


In this case, the downloaded resource will be saved as wordpress-install.zip instead of its
original name.

The -O option makes unzipping archives in Linux more efficient, as you don’t need to retype the
full name.

Using wget command to save files in specified directory


You can utilize wget to place a file in another directory using the -P function:

wget -P documents/archives/ https://wordpress.org/latest.zip


The file you retrieve using this syntax will appear in the documents/archives/ folder.

Using wget command to limit download speed


With wget, you can also limit the download speed. This is useful when retrieving huge files and
will prevent the command from using all of your bandwidth. This wget example will set the limit
to 500k:

wget --limit-rate=500k https://wordpress.org/latest.zip


Using wget command to set retry attempts
Internet connection problems can interrupt your download. To tackle this issue, we can increase
the retry attempts using the -tries function:

wget -tries=100 https://wordpress.org/latest.zip


Using wget command to download in background
For extremely large files, you may take advantage of the -b function. It will download your
content in the background.

wget -b http://example.com/beefy-file.tar.gz
A wget-log will appear in your working directory, which can be used to check your download
progress and status. You can also use the tail command:

tail -f wget-log
Using wget command to download via FTP
The command is also usable with FTP. All you need to do is specify the username and
password like in this wget example:
wget --ftp-user=YOUR_USERNAME --ftp-password=YOUR_PASSWORD
ftp://example.com/something.tar
Using wget command to continue interrupted downloads
Your download can get interrupted if you lose the internet connection or experience a power
outage. This is quite a common occurrence when getting huge files. Instead of starting over, it’s
possible to continue the download using the -c function:

wget -c https://example/very-big-file.zip
If you proceed without the -c function, the new file will have .1 added at the end as it already
exists.

Using wget command to retrieve whole websites


It is also possible to use the wget command to download the content of an entire site. This will
let you view it locally without an internet connection. Here is an example:

wget --mirror --convert-links --page-requisites --no-parent -P documents/websites/ https://some-


website.com
Let’s analyze the ingredients of this wget command:

–mirror Makes your download recursive.


–convert-links All links will be converted for proper offline usage.
–page-requisites The following will include all necessary files such as CSS, JS, and
images.
–no-parent Ensures that directories above the hierarchy are not retrieved.
-P documents/websites/ Ensures that the following will include all necessary files, such as
CSS, JS, and images.

You might also like