How to Use Wget to Download Files on Lin
Wget is a powerful command line tool that can be used to download files from the internet. It is available on Linux, Windows, and macOS, and can be used to download files from FTP, HTTP, and HTTPS protocols. In this article, we will discuss how to use Wget on Linux to download files.
Step 1: Install Wget
Wget is usually installed by default on most Linux distributions. However, if it’s not installed on your system, you can install it using your distribution’s package manager. For example, on Ubuntu, you can type the following command in the terminal:
sudo apt-get install wget
Step 2: Get the file URL
Before you can use Wget to download a file, you need to know its URL. This is the address of the file on the internet. You can find the URL of the file by navigating to the page where the file is located and copying the URL from the browser’s address bar.
Step 3: Download the file
Once you have the file URL, you can use Wget to download it. To do this, open the terminal and enter the following command:
wget [file URL]
For example, if the file URL is https://example.com/myfile.zip, you would enter the following command:
wget https://example.com/myfile.zip
Wget will begin downloading the file and display a progress bar in the terminal. Once the download is complete, the file will be saved in the current directory.
Step 4: Specify the location to save the file
By default, Wget will save the downloaded file in the current directory. However, you can specify a different directory to save the file using the -P option. To use this option, enter the following command:
wget -P [directory] [file URL]
For example, if you want to save the file in the Downloads directory, you would enter the following command:
wget -P ~/Downloads https://example.com/myfile.zip
This will download the file and save it in the Downloads directory.
Step 5: Download multiple files
You can use Wget to download multiple files at once by specifying a list of file URLs in a text file. To do this, create a text file and list the URLs of the files you want to download, one URL per line. For example:
https://example.com/file1.zip
https://example.com/file2.zip
https://example.com/file3.zip
Save the file and name it urls.txt. Then, open the terminal and enter the following command:
wget -i urls.txt
This will download all the files listed in the urls.txt file and save them in the current directory.