What is wget?

While there are many different ways to download files from the internet, most of them rely on the use of a web browser or some other piece of software. For instances where you simply want to download a single file from an online source, you may find the wget command to be the perfect solution. As this command can be issued from any Linux command-line interface, wget is a simple and effective way to directly download remote files to your personal computer or your web server. In this article, we will discuss the benefits of using wget as well as explore how wget is used for file downloads.

Topics Include:

Use wget to download your important data to your Dedicated Hosting server!

Why use wget?

Wget is a command-line utility that allows for file transfers using common transfer protocols including, HTTP, HTTPS, and FTP. This utility comes pre-installed with all Linux operating systems and requires no configuration to use. Rather than installing FTP clients such as Filezilla or LFTP, users looking to download select files from a remote source can simply use wget to immediately perform the transfer. This can save time and effort by removing the configuration process typically associated with traditional FTP clients.

As wget does not require login information or specific server settings, there is virtually no setup involved. In order to download a file using wget, all you need to know is the hostname of the server and the location of the file you wish to download. It is important to note that file permissions will also need to be set correctly in order to allow wget to access the file using one of the aforementioned protocols. In the next section, we will explore how wget can be used to download files from a remote server.

Using wget

In order to use wget, you will first need to login to your server via SSH. If you are performing this task on your personal Linux computer, all you need to do is open your preferred terminal application. Once in the command-line, you can use the wget command as follows:

wget https://server.name/path/to/file.txt

In this example, server.name is the server hostname or domain name associated with the server you are attempting to access. The protocol must be specified in the command, in this case it is https://. The portion /path/to/file.txt is the location of the target file file.txt within the remote server’s file structure. When running the command, you should see a progress bar that provides the status of the transfer as well as details regarding transfer rates. Once the transfer has finished, the file will appear on the destination server with the same file name, which in this case is file.txt.

If you would like to modify the name of the file while transferring it using wget, you can use the -O flag to modify the file name as follows:

wget -O newfile.txt https://server.name/path/to/file.txt

In this example, the file file.txt will be saved to the folder that you ran the command from as newfile.txt. This location is generally referred to as the destination folder. This option is particularly useful in occasions where it is necessary to download duplicates of the same file. 

Congratulations, you now know how to download a file using wget!

InMotion Hosting Contributor
InMotion Hosting Contributor Content Writer

InMotion Hosting contributors are highly knowledgeable individuals who create relevant content on new trends and troubleshooting techniques to help you achieve your online goals!

More Articles by InMotion Hosting

Was this article helpful? Join the conversation!

Questions about our MailChannels Deployment? We have answers and are here to help!Learn More
+