Using the wget command

Install the wget software package with the following command:

sudo apt-get install wget

After the installation is completed, you can now start using the wget command on your server.

1. Wget Command to Download a single file
The most common and simple usage of wget is to download a single file and store it in your current directory.

For example, to download the latest WordPress version you can use the following command:


In this command will download the file and save it in your current directory under the “” name.

2. Wget Command to Download a file and save it under different name
You may want to save the file under a different name. To do this, you can use the -Ooption like this:

wget -O

This will download and save the latest WordPress installation in your current directory under the name “”.

3. Wget Command to Download a file and save it in specific directory
To download the file and save it in a different directory, you can use the -P option, for example:

wget -P /opt/wordpress

This will download and store the file in the /opt/wordpress directory on your server.

4. Wget Command to Set the download speed
If you happen to download a huge file which takes longer to complete, you can also limit the download speed to prevent wget from using the full possible bandwidth of your connection.

To limit the download speed to 300k, for example, you can use the following command:

wget –limit-rate=300k

5. Wget Command to Continue interrupted download
Sometimes, when you download a very big file which would take a longer time to complete, you may temporarily lose your internet connection and your download will get interrupted.

To avoid starting the whole download again, you can continue from where it got interrupted using the -c option:

wget -c

If the download is interrupted, and you start the whole download again without the -c option, wget will append “.1” to the end of the filename because the filename with the previous name already exists.

6. Wget Command to Download in background
For bigger files, you can also use the -b option, to download the file in the background.

wget -b

The output will be written in the “wget-log” file in the same directory, and you can always check the status of the download with the following command:

tail -f wget-log

7. Wget Command to Increase retry attempts
If you are having issues with your internet connection, and your download is getting interrupted multiple times, you can increase the retry attempts to download the file with the -tries option:

wget -tries=100

8. Wget Command to Download multiple files
If you want to download multiple files at the same time, you can create a text file (for example download.txt) where you place all the URLs of the files you wish to download. To create a text file do the following:

touch download.txt
Then you can edit the file with nano, and enter all the URLs of all the files you want to download:

nano download.txt

After you save the file, you can then use the -i option to download all the files stored in that text file:

wget -i download.txt

9. Wget Command to Download through FTP
You can also use wget to download a file directly through FTP using a set username and password, with the following command:

wget –ftp-user=username –ftp-password=password ftp://url-to-ftp-file

10. Wget Command to Download entire website
You can even use wget to download an entire website, which you can then view locally, offline, without the need of internet connection. To do this you can use the following comand:

wget –mirror –convert-links –page-requisites —-no-parent -P /path/to/download

With —mirror, you turn on all the options required for mirroring.

With –convert-links, you will convert all the links so they would work offline.

With –page-requisites, you download all the necessary files such as CSS style sheets and images required to properly display the pages offline.

With –no-parent, you can restrict the download only to a specific portion of the site.

Additionally, you can set the path to where we want to download the files with the -P command followed by the path to the directory.