en
  English
Phone :  +370 (5) 204-1903
Email: sales@1gbits.com

Wget commands

Wget is a GNU command-line tool. It is available for free of cost over the internet. You can use this tool to download several files from the internet. 

Linux Tutorial Jul 02, 21 by Nisal N 6 min Read
Wget commands

There are various protocols that it uses to retrieve numerous 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. 

Beneficial, right?

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 certain 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
  • Process to install wget on Ubuntu and CentOS
  • How to install wget on Windows
  • Wget commands

Let's begin!

Check wget installation

Generally, wget packages come pre-installed on Linux. Hence, they are by default present in your device. But, in case you want to double-check, go to your terminal window and type the following command:

wget

If there is the wget software, then the output showcases a missing URL, as you can see in the below-given snapshot.

On the other hand, if you see an output that says, wget command not found, then you have to download and then 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

That’s it! 

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 after the configuration, there is no need for full paths. 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.

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 either a file or a directory that 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:

wget [URL]

  • 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 full 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 as 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 that you’ll need for downloading 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]

Conclusion

As you can see, wget is an extremely powerful tool to download 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. 

author img

Nisal N

Computers has always fascinated me since I was a kid and here we are. I love travelling for 2 reasons: the first one to see a new part of the world and second (the most important one) to experience the rich culture hidden among the country and people. I'm pretty good at cooking but very poor when it comes to baking.

Leave A Comment