List of content you will read in this article:
There are various protocols that it uses to retrieve multiple files. For instance, HTTP FTP and HTTPS protocols.
Moreover, during the download process, if any sort of network problem occurs, wget has the ability to retrieve the files from the point where the connection was lost.
It is an incredible tool for tackling unstable and slow network connections. There are several benefits associated with wget.
Take a look:
- You can recursively download the files
- It also helps you to transfer specific parts of a website via links and the structure of a directory.
- During the process of download, you do not have to stay logged in or active.
- This tool is non-interactive, which means it can work well independently
Moving on, when we talk about wget command, it is extremely flexible, as you can use it in scripts, terminals, or cron jobs.
There are various wget commands. We are here to present you with a list along with an explanation.
Before this, take a look at the major pointers that will be covered in this article!
- Check wget installation
- The process to install wget on Ubuntu and CentOS
- How to install wget on Windows
- Wget commands
Check wget installation
Generally, wget packages come pre-installed on Linux. Hence, they are, by default, present on your device. But, in case you want to double-check, go to your terminal window and type the following command:
If there is the wget software, the output showcases a missing URL, as you can see in the screenshot below.
On the other hand, if you see an output that says, wget command not found, you have to download and manually install the tool.
In this scenario, you may wonder, how to install wget? Well, we are here with the procedure to install this incredible tool on your respective systems.
The process to install wget on Ubuntu and CentOS.
If you want to install the tool on Ubuntu, type in the following command:
sudo apt-get install wget
On the other hand, if you are using CentOS, you can insert the below-stated command:
sudo yum install wget
Yes, it’s this simple!
Now, if you are a Windows user, follow up the process in a step-by-step fashion, and get the tool on your system!
How to install wget on Windows?
Here are the steps if you wish to install and configure wget on Windows:
1. The first step is to download wget and begin installing the package.
2. Now, insert the wget bin path to the environment variables. This step is optional, but there is no need for full paths after the configuration. Therefore, it becomes easy for you to run wget through the command prompt.
- Click on the start menu and search environment
- Choose Edit the system environment variables
- Tap on the advanced tab. After that, hit on the environment variables button.
- Under system variables, choose the path variable
- Press Edit
- Now, you will see the variable value field. Here, add the path to the wget bin directory.
3. The next step is to go to your command prompt and start executing wget commands.
First of all, let us introduce you to the basic syntax of wget. Here it is!
wget [option] [URL]
Option attribute defines the task to be done with the URL ahead of it.
Next up is the URL; it’s nothing but the address of a file or a directory you want to download.
Let’s now begin with some examples of the wget commands.
- If you wish to download a file from the web, you can use the below-mentioned command:
- Use the following command if you want to download a file and mention a specific name:
wget -0 [file_name] [URL]
This command allows you to rename the files before downloading them on the device.
- If you wish to save a file in a specific location, you can use the following command:
wget –P [wanted_directory] [URL]
- To download a heavy file, you have the option to set the download speed according to your wish. This way, the file is unable to use the total bandwidth available. Type in the following command to set the same:
wget --limit-rate [wanted_speed] [URL]
- There is another advantage of wget that the download starts from the point where it was stopped. This command comes in handy when the connection is lost during a file download. Use this command to start the download again:
wget -c [URL]
- At the same time, you can also download several files using this command:
wget -i [file_name]
To accomplish this task, you have to follow some steps mentioned below:
- Create a file with any name
- When you open the editor, insert the URLs of the packages you wish to download.
- Save this file and exit.
- Open your terminal window and write the following command: wget –i MultipleDownloads.txt.
This command prompts you to download from each mentioned URL.
- If you wish to download the whole website, you can use the -m option. A replica of the mentioned website is made by this wget command. Take a look:
wget -m [URL]
- In case you want to download through FTP, you need to type both the username and password of the FTP server and then the FTP address, as stated below:
wget --ftp-user=[ftp_username] --ftp-password=[ftp_password] ftp://…
- To download any file in the background and resume your work alongside. To do that, you can use the below-mentioned command:
wget -b [URL]
- If you face a bad network, you can also set the number of attempts you’ll need to download the file. Use this command:
wget --tries=[number_of_tries] [URL]
- wget automatically checks whether your server has an authentic SSL certificate or not. If not, it does not download files from that web page.
wget --no-check-certificate [URL]
As you can see, the wget command is an extremely powerful tool for downloading various files on the web. Also, there are numerous features associated with this tool.
This article made you familiar with the uses of wget commands as well as their execution. We hope that the information helps you to clarify all your ambiguities related to the wget command.
People also read: