Updated July 3, 2023
Introduction to Linux wget
In the Linux ecosystem, wget is a utility to get or download files from the internet or any data provider. It is compatible with protocols like HTTP, HTTPS, and FTP. It is also known as a non-interactive network downloader. Hrvoje Niksic wrote this utility.
Syntax of wget command:
wget [option]... [URL ]...
- wget: We can use the wget keyword in the syntax or command. It will take the two-argument as an option and URL. Provide the end result with the download file.
- option: We can provide the different flags as options that are compatible with wget command.
- URL: We can pass the full qualified URL to the wget command as per the requirement.
How does Linux wget Command work?
- The wget is a non-interactive utility.
- Basically, it is more robust and safe to get files from different platforms.
- The wget utility is designed in such a way that it will work in an unstable or slow network.
- When any file is trying to download but due to network connection, the file is not downloaded completely.
- Then wget command will download the same file with the last download point.
- It will not fully download the same file from starting.
- It will also download the files recursively.
- The wget commands work on the wget option and the wget download URL.
- As per the set of arguments, the wget command will download the file.
Examples of Linux wget
Given below are the examples:
It is the basic command of wget. It will download the single file from the provided URL. It will also provide the file download timestamp and status bar.
Note: By default, the wget package is not present in the Linux operating system.
We need to download it as per the below command.
"yum install wget"
- As per the below output screenshot, we are in the data directory. There are no data/files present in it.
- Using the wget command, we are able to download the wget file form the internet. It will store the download file in the current or working directory.
wget command – Download file with own filename
In Wget, we have the provision to give the own file name for any download file. We need to use the “-O” option with wget command.
wget -O test-file.tar.gz http://ftp.gnu.org/gnu/wget/wget-1.20.tar.gz
- As per the above command, we are using the “-O” option with wget command.
- It is useful to change the download file name to our own file name. Here, we are using “test-file.tar.gz” as our own file name.
wget command – Download Multiple Files
In wget, we have the functionality to download multiple files in the same command. We need to provide the multiple download URL to the wget command.
wget http://www.africau.edu/images/default/sample.pdf http://ftp.gnu.org/gnu/wget/wget-1.20.tar.gz
- As per the above command, we are able to download multiple files at the same time. We just need to pass the multiple URL in the command.
- We have passed the sample pdf URL and tar file URL. At the end result, we will get both files in the same working directory.
wget command – Download from File URL
In wget, we are able to download the number of files from the internet with the help of the URL file. URL File is nothing but a simple file into which we have copied the entire download URL’s.
wget -i url.txt
- We have kept the entire download URL in “url.txt” file and passing the file to the wget command.
wget command – Resume Download
In the wget command, we have the functionality to resume the older download. It will not newly download the file. It will resume the download from the last download instance.
wget -c http://centos.mirror.snu.edu.in/centos/8.1.1911/isos/x86_64/CentOS-8.1.1911-x86_64-dvd1.iso
- As per the above command, we are able to resume the older download file.
- The download file was manually stopped. But with the help of the “-c” option, we can resume the download file.
wget command – RestrictBandwidth
The tool is used to get detailed information on the Wget interface.
wget -c --limit-rate=50k http://centos.mirror.snu.edu.in/centos/8.1.1911/isos/x86_64/CentOS-8.1.1911-x86_64-dvd1.iso
- We can restrict bandwidth utilization while downloading the file to avoid a network bandwidth issue.
- As per the network speed, we can define the bandwidth utilization for download. Here we have to define 50KB as the download speed.
wget command – Download with a User ID and Password
As per the secure download, we can provide the login credentials details in wget command.
wget --http-user=educba --http-password=educba123 http://centos.mirror.snu.edu.in/centos/8.1.1911/isos/x86_64/CentOS-8.1.1911-x86_64-dvd1.iso
- As per the security point of view, we can provide the login id and password while downloading any particular or secured file from the HTTP and FTP protocols.
wget command- Download in Background
With the help of the wget command, we are able to download the files in the background.
wget -b http://centos.mirror.snu.edu.in/centos/8.1.1911/isos/x86_64/CentOS-8.1.1911-x86_64-dvd1.iso
- As per the below screenshot, we are downloading the file in the background.
wget command- Help and Version
We are able to get the wget version and command help. It will help to understand the working of the wget command.
- When we need to explore more about the wget command, we can use the “–help” option.
- It will provide all the basic information like different option, command, etc.
- The version information we will provide the wget version details. Which is used in the current Linux Server.
We have seen the uncut concept of “Linux wget command” with the proper example, explanation, and command with different outputs. The wget command is used to download the files form the internet or intranet. It is a secure way to download the files.
We hope that this EDUCBA information on “Linux wget” was beneficial to you. You can view EDUCBA’s recommended articles for more information.