How to Install and Use Wget on Linux

How to Install Wget on Linux

Wget is a non-interactive network download utility for the Linux command line interface. It’s is used for downloading or retrieving files from web servers or FTP servers. Wget can be installed on most modern operating systems, including Windows, Linux, and macOS.

Wget Usage

The Wget command comes with several options that allow you to download multiple files, download in the background, mirror a website, resume downloads, limit the bandwidth, download recursively, and lots more. It supports HTTP, HTTPS, and the FTP protocols and also retrieval through HTTP proxies.

In this tutorial, we will show you how to install and use Wget command with some examples on how to use Wget.

Requirements

  • A Linux VPS with root access enabled or a user with sudo privileges. Our VPSes all come with root access included.

Connect to Your Server

Before starting, you need to connect to your server via SSH as the root user or as any other user with sudo privileges.

To connect to your server as the root user, use the following command:

ssh [email protected]_ADDRESS -p PORT_NUMBER

Make sure to replace IP_ADDRESS and PORT_NUMBER with your actual server IP address and SSH port number. The default port number is 22, so try that one first if you’re not sure.

Once logged in, make sure that your server is up-to-date by running the following commands:

apt-get update -y

Or

yum update -y

Now that everything is up to date, we can install Wget and see how to use it.

Install Wget

By default, the Wget package comes pre-installed in most Linux operating systems. If not installed, you can install it using either the APT or YUM command-line utility (depending on your Linux distribution).

For RHEL/CentOS/Fedora, install Wget by running the following command:

yum install wget -y

For Debian/Ubuntu, install Wget by running the following command:

apt-get install wget -y

Once installed, you can verify the installed version of Wget command using the following command:

wget --version

Output:

GNU Wget 1.15 built on linux-gnu.

Download a Single File

You can use the Wget command without any options specified to download a file from the specified URL to your current working directory.

For example, download this Drupal install file using the Wget command, as shown below:

wget https://ftp.drupal.org/files/projects/drupal-8.7.3.tar.gz

You should see the following screen:

In the above screen, you can see the progress bar, downloaded file size and download speed.

Download Multiple Files

The Wget command also allows you to download multiple files by specifying multiple URLs.

For example, the following command will download Drupal and WordPress files:

wget https://ftp.drupal.org/files/projects/drupal-8.7.3.tar.gz https://wordpress.org/latest.zip

You should see the following screen:

In some cases, you might want to download a large number of files. In this case, you can store all URL’s in a text file and download them using the -i option.

First, create a text file using the following command:

nano download.txt

Add all the URL’s that you want to download:

https://ftp.drupal.org/files/projects/drupal-8.7.3.tar.gz 
https://wordpress.org/latest.zip

Save and close the file.

Next, use the Wget command with the -i option to download all files:

wget -i download.txt

You should see the following screen:

Download Files and Save them with a Different Name

You can download a file and save it with a different name by using the -O option:

wget -O wordpress.zip https://wordpress.org/latest.zip

You should see the following screen:

Resume an Incomplete Download

If you are downloading a large file and stop the downloading process due to some network error, you can resume downloading the same file where it was left off with the -c option.

For example, let’s download the WordPress file using the -c option:

wget -c https://wordpress.org/latest.zip

Press CTRL + C to stop the downloading process:

Now, run the above command again:

wget -c https://wordpress.org/latest.zip

This will download the file where it was left off, as shown below:

Download a File in the Background

You can also use the Wget command with the -b option to run the downloading process in background.

wget -b https://ftp.drupal.org/files/projects/drupal-8.7.3.tar.gz

This command will save the downloading progress log in the wget-log file in the current directory.

You can check it with the following command:

tail -f wget-log

Limit the Download Speed

The Wget command also allows you to limit the download speed by using the --limit-rate option.

For example, download the WordPress file and limit the download speed to 256KBps, as shown below:

wget --limit-rate=256k https://wordpress.org/latest.zip

You should see the following screen:

This option is very useful if you don’t want Wget to use all of your available bandwidth.

wget Command Advance Usage

If you want to download a file using the HTTPS protocol from a server that has an invalid SSL certificate, you can use the --no-check-certificate option:

wget --no-check-certificate https://wordpress.org/latest.zip

To create a mirror of any website, you can use the -m option. This will download a complete local copy of the specified website:

wget -m http://example.com

If you want to download a file from a password-protected FTP server, use the following command:

wget --ftp-user=ftpuser --ftp-password=ftppassword ftp://your-ftp-server/file.zip

Hopefully you now have a clearer view of what Wget can do for you. It’s a useful application whose features are rarely ever used outside of the most basic function.


Wget Linux

Using Wget on your server is easy, but you’re probably using it to download and install some software on your server. Our managed Linux VPS hosting gives you the freedom to never have to download and install programs ever again. Just ask our admins to install and configure any software that you need, and they’ll have it handled immediately. It’s completely free and they’re available to help you 24/7. They also handle maintenance and optimization to keep your server running at its fastest for a long time.

If this tutorial gave you the help you needed for installing Wget, maybe consider sharing it through the use of our share shortcuts. You can also leave any questions or suggestions in our comments section below. Thank you.

Leave a Comment

To prove you are human please solve the following *