Most Linux distributions have Wget installed by default. First, type wget
in your terminal and press ENTER
. If it is not installed, it will display command not found
or -bash: /usr/bin/wget: No such file or directory
. You can install it by running the following command:
sudo apt-get install wget
sudo yum install wget
First, create a directory in your home directory
and enter it to save the files that you will download throughout this tutorial:
mkdir ~/wget && cd ~/wget
Now, you have successfully created the directory where you will store the files you download.
Type wget followed by the URL of the file that you wish to download. Wget will download the file in the given URL and save it in the current directory.
In the following example, we are downloading the favicon of vpsname.com
.
wget https://vpsname.com/favicon.ico
The output will look similar to this image, you can replace the URL you want to download.
Then you can check the file of the current directory using the following command:
ls
If the file name already exists, wget
will add .N
(number) at the end of the file name. So far, you know how to use wget to download files to the current directory.