So you were following one of our tutorials which involves the usage of wget to download some files and you got an error like this:
"Command 'wget' not found, but can be installed with:"
It means the wget package is not present in your system so what should be your next step? Of course, installation!
How to install wget in Ubuntu
wget is available in the Ubuntu repositories. You can install it with this simple command:
sudo apt install wget
And to make sure the installation was successful, you can use the given command to check for the installed version:
How to use Wget in Ubuntu
After installation, I'd like to walk you through some basic examples of wget so you can have a better idea of its use case.
How to download Files using wget
To download files using wget, you just have to follow the simple syntax as follows:
So I wanted to install Pop!_OS Linux so why not download its ISO using wget?
How to download files with specific filename
I often find the default filenames too long and irrelevant for my usage but wget allows you to choose the filename of your choice even before the download starts!!
And that can be achieved through the given syntax:
wget -O [file_name] [URL]
How to download files to a specific directory
To download files in a specific directory, users are required to use
-P and appending the path where you want to save the file.
Sound complex? here's the syntax:
wget -P [Path_to_save_file] [URL]
Let's say I want to download a png file inside the directory named
Images then my command will be:
How to resume downloading after interruption
Suppose you were about to complete a download file worth 50-60 gigs and suddenly due to a network issue, the process gets interrupted.
I can't resolve network issues of your system but I show you a way how to resume downloads using wget through simple syntax:
wget -c [URL]
For example, I'll be resuming the download of Pop!_OS:
How to download files in the background
To download files in the background, you just have to pair wget with
-b option and your output will be stored at
wget -b [URL]
And in the case where you want to monitor the download process, you can use the tail command with
tail -f wget-log
So you can download files using wget but curl can do the same right? so what's the difference? Well, here's the answer:
Through this guide, I explained how you could install and use wget command in Ubuntu.
And if you have any queries, feel free to ask in the comments!