The Wget is a command-line utility that is used to download files and webpages from the web. Various internet protocols like HTTP, HTTPS, and FTP can be used to access and retrieve the files. We can specify the different options with the Wget command in order to perform different options.
This article explains the use of the Wget command to download the file from the command-line. Moreover, we have explained the use of various common options with their practical examples too.
The Wget command comes pre-installed on many Linux-based distributions, including Ubuntu. To verify either the Wget command is installed on your system or not, open up the terminal and execute the following command:
The output confirms that the Wget command is installed on my system. However, if the Wget command is not installed, then you can install it on your Ubuntu and other Debian based systems with the command below:
First, let’s discuss the syntax of the command. The syntax of the Wget command is as follows:
Multiple options can be used with the wget command. The url refers to the address of the file that we need to download.
The simplest form of the Wget command is to use it without specifying any options. The Wget command downloads the files from the given url in the current working directory. For instance, let’s download the Skype Debian package with the appended Wget command below:
The Wget command sends the HTTP request and downloads the Debian package in the current directory.
In addition, it displays the progress bar, file size, download speed, etc.
Normally, the files are downloaded and saved with the original name. But, the Wget command allows us to rename the files before downloading using the –O option. After the –O option, we need to specify the filename:
The Skype package name has changed to ‘Skype’.
As previously discussed, the files are saved in a current working directory. Nevertheless, the downloaded files can be saved in any other specific directory using the –p option. Let’s download the file and save it in the ‘Downloads’ directory with the below-given command:
The skypeforlinux-64.deb file is successfully downloaded and saved in the ‘Downloads’ directory.
We can set a specific download speed for a file with the –limit-rate option. The downloading speed is measured in bytes/second by default. However, we can set the downloading speed in kilobytes (k), megabytes (m), and gigabytes (g).
In the above-given command, the downloading speed is limited to 500 kilobytes per second.
If the downloading is interrupted, then you can easily resume it with the -c option.
I have interrupted a download by pressing ctrl-c. Let’s resume this download with the appended command:
By using the Wget command, we can download multiple files as well. Store the file’s URLs in a text file whereas each URL starts on a new line. Use the -i option and specify the text file name next to it.
Let’s download the Linux Kernel 5.10 file.
Both the Linux kernel files are downloaded successfully.
You can put your downloading process in the background with the -b option. Ideally, we do it while downloading the big file.
The downloading will be continued in the background.
The Wget is a very useful command-line utility for downloading files from the command-line. It comes pre-installed on Ubuntu 20.04 and many Linux distributions. With the Wget command, we can download the files, save them with different names, save them in any other specified directory rather than the current working directory, and many more.
Our latest Canonical website rebrand did not just bring the new Vanilla-based frontend, it also…
At Canonical, the work of our teams is strongly embedded in the open source principles…
Welcome to the Ubuntu Weekly Newsletter, Issue 873 for the week of December 29, 2024…
Have WiFi troubles on your Ubuntu 24.04 system? Don’t worry, you’re not alone. WiFi problems…
The following is a post from Mark Shuttleworth on the Ubuntu Discourse instance. For more…
I don’t like my prompt, i want to change it. it has my username and…