Linux wget command with examples

In this article, we will learn Linux wget command with examples step by step.

wget is a command-line utility used to download files from the web. With wget, you can download files using HTTP, HTTPS, and FTP protocols. Linux wget provides a number of options allowing you to download multiple files, resume downloads, limit the bandwidth, recursive downloads, download in the background.

Install wget if not installed using below command.

On Ubuntu and Debian:

sudo apt-get install wget

On Fedora and CentOS or Redhat:

sudo yum install wget

Linux wget Syntax:

wget [otions] url

Linux wget command examples:

1. To get help use the following commands. These commands will display the Syntax and wget command options.

man wget wget --help

2. To get wget version:

wget --version

3. Download a file using wget. Following downloads MySQL sample database in zip format.

wget https://downloads.mysql.com/docs/sakila-db.zip

Linux wget command with examples

4. Download file different name using Linux wget command.

wget -O wget.zip http://ftp.gnu.org/gnu/wget/wget-1.20.3.tar.lz

Lets verify:

5. Download multiple with Linux wget command.

wget http://ftp.gnu.org/gnu/wget/wget-1.6.tar.gz http://ftp.gnu.org/gnu/wget/wget-1.16.1.tar.gz

6. Download a File to a Specific Directory

wget -P /mnt/iso http://centos.mirror.snu.edu.in/centos/8-stream/isos/x86_64/CentOS-Stream-8-x86_64-20201203-dvd1.iso

7. Limit the download speed with Linux wget command.

To limit the download speed, use the –limit-rate option. By default, the speed is measured in bytes/second. Append k for kilobytes , m for megabytes and g for gigabytes.

wget --limit-rate=2m https://dl.google.com/go/go1.10.3.linux-amd64.tar.gz

8. Resume a download with Linux wget. We can resume download with -c option.

wget -c https://dl.google.com/go/go1.10.3.linux-amd64.tar.gz