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 different protocols like HTTP, HTTPS, FTP, etc. It is also known as a non-interactive network downloader. This utility was written by Hrvoje Niksic.
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: As per the requirement, we can pass the full qualified URL to the wget command.
How does Linux wget Command work?
- The wget is non-interactive utility.
- Basically it is more robust and safe to get the files from different platforms.
- The wget utility is design 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 was 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 are working on the wget option and 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. Parallelly, it will also provide the file download timestamp and download 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 are having 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 own file name.
wget command – Download Multiple Files
In wget, we are having the functionality to download the 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 the 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 the 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 are having the functionality to resume the older download. It will not newly download the file. It will resume the download from 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 ethtool tool is used to get the detail information of 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
- To avoid a network bandwidth issue, we can restrict bandwidth utilization while downloading the file.
- As per the network speed, we can define the bandwidth utilization for download. Here we have to define 50KB as download speed.
wget command – Download with 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 are able to provide the login id and password while downloading any particular or secured file form the HTTP as well as FTP protocols.
wget command- Download in Background
With the help of wget command, we are able to download the files in 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 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 using 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.
This is a guide to Linux wget. Here we discuss the introduction to Linux wget, how wget command works and programming examples. You may also have a look at the following articles to learn more –