Use Wget to Downloading File

Last Updated: Tue, July 19, 2022

Prerequisites

Install Wget

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:

Debian / Ubuntu

sudo apt-get install wget

CentOS / Fedora

sudo yum install wget

Download with 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.

Downloading a file

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.
Use Wget to Downloading Files

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.


If you interest in my articles, please consider buying me a coffee.

Write Your Comment