Skip to content
Bots!
Bots!
  • About
    • Myself
    • আমার দোয়া
  • Bookmarks
    • Bookmarks
    • My OCI Bookmarks
    • Useful Proxmox Commands & Links
    • Learning Nano
    • Useful Sites
    • Useful Virtualbox Command
    • Useful MySQL Command
    • Useful Linux Command
    • BTT-CAS
  • Resources
    • Webinar on Cloud Adoption for Project Managers
  • Photos
  • Videos
  • Downloads
Bots!

Wget Command Examples

Rumi, April 30, 2020

How to Download a File with Wget

In it’s simplest form when used without any option, wget will download the resource specified in the [url] to the current directory.

In the following example we are downloading the Linux kernel tar archive:

wget https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.17.2.tar.xz

As you can see from the image above, Wget starts by resolving the IP address of the domain, then connects to the remote server and starts the transfer.

During the download, Wget shows the progress bar alongside with the file name, file size, download speed, and the estimated time to complete the download. Once the download is complete, you can find the downloaded file in your current working directory.

To turn off Wget’s output, use the -q option.

If the file already exists, Wget will add .N (number) at the end of the file name.

Using Wget Command to Save the Downloaded File Under Different Name

To save the downloaded file under a different name, pass the -O option followed by the chosen name:

wget -O latest-hugo.zip https://github.com/gohugoio/hugo/archive/master.zip

The command above will save the latest hugo zip file from GitHub as latest-hugo.zip instead of its original name.

Using Wget Command to Download a File to a Specific Directory

By default, Wget will save the downloaded file in the current working directory. To save the file to a specific location, use the -P option:

wget -P /mnt/iso http://mirrors.mit.edu/centos/7/isos/x86_64/CentOS-7-x86_64-Minimal-1804.iso

With the command above we are telling Wget to save the CentOS 7 iso file to the /mnt/iso directory.

How to Limit the Download Speed with Wget

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.

The following command will download the Go binary and limit the download speed to 1mb:

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

This option is useful when you don’t want wget to consume all the available bandwidth.

How to Resume a Download with Wget

You can resume a download using the -c option. This is useful if your connection drops during a download of a large file, and instead of starting the download from scratch, you can continue the previous one.

In the following example we are resuming the download of the Ubuntu 18.04 iso file:

wget -c http://releases.ubuntu.com/18.04/ubuntu-18.04-live-server-amd64.iso

If the remote server does not support resuming downloads, Wget will start the download from the beginning and overwrite the existing file.

How to Download in Background with Wget

To download in the background ,use the -b option. In the following example, we are downloading the OpenSuse iso file in the background:

wget -b https://download.opensuse.org/tumbleweed/iso/openSUSE-Tumbleweed-DVD-x86_64-Current.iso

By default, the output is redirected to wget-log file in the current directory. To watch the status of the download, use the tail command:

tail -f wget-log

How to change the Wget User-Agent of Wget

Sometimes when downloading a file, the remote server may be set to block the Wget User-Agent. In situations like this to emulate a different browser pass the -U option.

wget --user-agent="Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0" http://wget-forbidden.com/

The command above will emulate Firefox 60 requesting the page from wget-forbidden.com

How to Download Multiple Files with Wget

If you want to download multiple files at once, use the -i option followed by the path to a local or external file containing a list of the URLs to be downloaded. Each URL needs to be on a separate line.

In the following example we are downloading the Arch Linux, Debian, and Fedora iso files with URLs specified in the linux-distros.txt file:

wget -i linux-distros.txt
linux-distros.txt
http://mirrors.edge.kernel.org/archlinux/iso/2018.06.01/archlinux-2018.06.01-x86_64.iso
https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-9.4.0-amd64-netinst.iso
https://download.fedoraproject.org/pub/fedora/linux/releases/28/Server/x86_64/iso/Fedora-Server-dvd-x86_64-28-1.1.iso

If you specify – as a filename, URLs will be read from the standard input.

Using Wget Command to Download via FTP

To download a file from a password-protected FTP server, specify the username and password as shown below:

wget --ftp-user=FTP_USERNAME --ftp-password=FTP_PASSWORD ftp://ftp.example.com/filename.tar.gz

Using Wget Command to Create a Mirror of a Website

To create a mirror of a website with Wget, use the -m option. This will create a complete local copy of the website by following and downloading all internal links as well as the website resources (JavaScript, CSS, Images).

wget -m https://example.com

If you want to use the downloaded website for local browsing, you will need to pass a few extra arguments to the command above

wget -m -k -p https://example.com

The -k option will cause Wget to convert the links in the downloaded documents to make them suitable for local viewing. The -p option will tell wget to download all necessary files for displaying the HTML page.

How to Skip Certificate Check with Wget

If you want to download a file over HTTPS from a host that has an invalid SSL certificate, use the –no-check-certificate option:

wget --no-check-certificate https://domain-with-invalid-ss.com

How to Download to Standard Output with Wget

In the following example, Wget will quietly ( flag -q) download and output the latest WordPress version to stdout ( flag -O -) and pipe it to the tar utility which will extract the archive to the /var/www directory.

wget -q -O - "http://wordpress.org/latest.tar.gz" | tar -xzf - -C /var/www
Administrations Configurations (Linux) Wget

Post navigation

Previous post
Next post

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Myself…

Hi, I am Hasan T. Emdad Rumi, an IT Project Manager & Consultant, Virtualization & Cloud Savvyfrom Dhaka, Bangladesh. I have prior experience in managing numerous local and international projects in the area of Telco VAS & NMC, National Data Center & PKI Naitonal Root and CA Infrastructure. Also engaged with several Offshore Software Development Team.

Worked with Orascom Telecom-Banglalink, Network Elites as VAS partner, BTRC, BTT (Turkey) , Mango Teleservices Limited and Access to Informaiton (A2I-UNDP)

Currently working at Oracle Corporation as Principal Technology Solution and Cloud Architect.

You can reach me [h.t.emdad at gmail.com] and I will be delighted to exchange my views.

Tags

Apache Bind Cacti CentOS CentOS 6 CentOS 7 Debain Debian Debian 10 Debian 11 Debian 12 DKIM Docker endian icinga iptables Jitsi LAMP Letsencrypt Linux Munin MySQL Nagios Nextcloud NFS nginx pfsense php Postfix powerdns Proxmox RDP squid SSH SSL Ubuntu Ubuntu 16 Ubuntu 18 Ubuntu 20 Varnish virtualbox vpn Webmin XCP-NG zimbra

Topics

Recent Posts

  • Install Jitsi on Ubuntu 22.04 / 22.10 April 30, 2025
  • Key Lessons in life April 26, 2025
  • Create Proxmox Backup Server (PBS) on Debian 12 April 19, 2025
  • Add Physical Drive in Proxmox VM Guest April 19, 2025
  • Mount a drive permanently with fstab in Linux April 16, 2025
  • Proxmox 1:1 NAT routing March 30, 2025
  • Installation steps of WSL – Windows Subsystem for Linux March 8, 2025
  • Enabling Nested Virtualization In Proxmox March 8, 2025
  • How to Modify/Change console/SSH login banner for Proxmox Virtual Environment (Proxmox VE / PVE) March 3, 2025
  • Install Proxmox Backup Server on Debian 12 February 12, 2025

Archives

Top Posts & Pages

  • Install Jitsi on Ubuntu 22.04 / 22.10
©2025 Bots! | WordPress Theme by SuperbThemes