Skip to main content

Module 9: Networking

Lesson 83: wget Command

In this lesson, you'll learn how to use the wget command to download files from the internet using HTTP, HTTPS, FTP, and FTPS protocols in Linux.

The wget utility retrieves files from the World Wide Web (WWW) using widely used protocols like HTTP, HTTPS, FTP, and FTPS.

wget is a free command-line utility and network file downloader, which comes with many features that make file downloads easy, including:

  • Download large files or mirror complete web or FTP sites.
  • Download multiple files at once.
  • Set bandwidth and speed limit for downloads.
  • Download files through proxies.
  • Can resume aborted downloads.
  • Recursively mirror directories.
  • Runs on most UNIX-like operating systems as well as Windows.
  • Unattended/background operation.
  • Support for persistent HTTP connections.
  • Support for SSL/TLS for encrypted downloads using the OpenSSL or GnuTLS library.
  • Support for IPv4 and IPv6 downloads.

wget Command Syntax

The basic syntax of wget is:

$ wget [OPTION] [URL]

Check and Install wget

First, check whether the wget utility is already installed or not in your Linux system using the following command:

$ rpm -q wget          # RHEL/CentOS/Fedora and Rocky Linux/AlmaLinux
$ dpkg -l | grep wget  # Debian, Ubuntu and Mint

If wget is not installed, you can install it using your Linux system's default package manager as shown:

$ sudo apt install wget -y      # Debian, Ubuntu and Mint
$ sudo yum install wget -y      # RHEL/CentOS/Fedora and Rocky Linux/AlmaLinux
$ sudo emerge -a net-misc/wget  # Gentoo Linux
$ sudo pacman -Sy wget           # Arch Linux
$ sudo zypper install wget      # OpenSUSE

The -y option used here is to prevent confirmation prompts before installing any package.

wget Command Options

Option Description
-O FILE Download file with a different name
-i FILE Download multiple URLs listed in a file
-c Resume an aborted/incomplete download
-b Send the download to the background
--limit-rate=RATE Set download speed limit (e.g. 100k)
--ftp-user / --ftp-password Authenticate for FTP download
--http-user / --http-password Authenticate for HTTP download
--no-check-certificate Ignore SSL certificate verification
--recursive Download recursively (mirror a site)
--version Display wget version information
--help Display help information

1. Download a File with wget

The command will download a single file and store it in the current directory. It also shows download progress, size, date, and time while downloading.

$ wget http://ftp.gnu.org/gnu/wget/wget2-2.0.0.tar.gz
URL transformed to HTTPS due to an HSTS policy
--2023-10-01 18:29:01--  https://ftp.gnu.org/gnu/wget/wget2-2.0.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: 3565643 (3.4M) [application/x-gzip]
Saving to: 'wget2-2.0.0.tar.gz'

wget2-2.0.0.tar.g 100%[=============>]   3.40M   689KB/s    in 5.1s

2023-10-01 18:29:08 (689 KB/s) - 'wget2-2.0.0.tar.gz' saved [3565643/3565643]

2. Download a File with a Different Name

Using the -O (uppercase) option downloads files with a different filename. Here we have given the wget.zip filename as shown below.

Pro TecMint Β· Root Plan
This Article is for Root Members
Join Root to read the full article and unlock everything

Full Access to Every Article, Course & Certification Track

Join thousands of Linux professionals who use Pro TecMint to advance their careers.

Ad-free access to all premium articles
All courses: Learn Linux, Bash, Golang, Ubuntu and more
RHCSA, RHCE, LFCS & LFCA certification prep
New courses added every month
Private Telegram community & priority support
Root Plan
$8/mo
or $59/year billed annually
Save $37 with annual plan
Start Reading This Article in the Next 60 Seconds
Join Root Plan β†’