Linux wget Command with Examples
Linux wget Command with Examples
wget is a popular Linux command-line utility used to download files from the Internet or other network locations. The name comes from “web get.” It supports protocols such as HTTP, HTTPS, and FTP, making it useful for students, system administrators, developers, and testers. Unlike graphical download tools, wget works directly from the terminal and is especially useful for automated scripts.
Basic Syntax
The basic syntax of the command is:
$ wget [options] URL
For example, to download a file:
$ wget https://example.com/file.zip
The downloaded file is normally saved in the current working directory using the filename provided by the server.
Download a File with a Different Name
The -O option allows you to specify the output filename:
$ wget -O linux-guide.zip https://example.com/file.zip
This downloads the file and saves it as linux-guide.zip.
Download to a Specific Directory
Use the -P option to choose where the downloaded file should be stored:
$ wget -P /home/student/downloads https://example.com/file.pdf
This is convenient when organizing downloaded resources into separate directories.
Resume an Interrupted Download
Large downloads can fail because of network interruptions. The -c option allows wget to continue an incomplete download instead of starting again:
$ wget -c https://example.com/large-file.iso
This feature is particularly useful when downloading operating-system images or other large files.
Download Multiple Files
You can provide multiple URLs in a single command:
$ wget https://example.com/file1.pdf https://example.com/file2.pdf
wget downloads each file sequentially.
Download an Entire Website
The --mirror option can be used to create a local copy of a website:
$ wget --mirror https://example.com/
For educational purposes, this can help students study website structure. However, always respect website terms, robots policies, copyright, and server resources.
Limit Download Speed
You can control bandwidth usage with --limit-rate:
$ wget --limit-rate=500k https://example.com/video.mp4
Here, the download speed is limited to approximately 500 KB per second.
wget is valuable because it combines simplicity with automation. It can be used in shell scripts, server administration, software testing, DevOps workflows, backups, and automated data collection. Since it runs without a graphical interface, it is also ideal for remote Linux servers.