paint-brush
How To Use wget in Linuxby@trendoceans
782 reads
782 reads

How To Use wget in Linux

by Trend OceansJanuary 10th, 2021
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

10 wget command

Company Mentioned

Mention Thumbnail
featured image - How To Use wget in Linux
Trend Oceans HackerNoon profile picture

Recently, I have covered how to install wget in Linux with a few simple steps. So, many viewers requested how do we implement these in the practical world.

Today, we cover 10 wget most used command in Linux. But if you directly jump to these posts or don’t know what we are talking about right now.

Let’s Begin

Before jumping ahead for those who are directly reading these post. First, check whether wget is installed correctly in your system or not by typing the following command in your Linux terminal.

$ wget -V

If it outputs the version information, then you good to goo or get a message something like command is not found; make sure to read our recent post on installing wget in all major Linux distribution and then continuing from here.

Syntax

$ wget [OPTION] [URL]

1. Download the contents of an URL to a File

To download webpages of any site over the internet. Simply, write it URL with wget, and it will download and save in the current location.

$ wget https://www.gnu.org/software/wget/
$ ls
index.html

2. Download the files with different location

To download files with a different location, simply pass the option -o with wget and specify the location you want to have your file after download.


$ wget https://ftp.gnu.org/gnu/wget/wget-1.5.3.tar.gz -O /home/trendoceans/Documents/wget.tar.gz

3. Download a file from an HTTP server with authentication

Downloading files without any authentication is easier using wget. But to download files using authentication is no more than a piece of cake.

$ wget --user=username --password=password https://example.com
  • user: This option specify user username to access restricted area of the web page.
  • password: This option is use to authenticate user with the user username provided in –user.

In the above example, I have not mentioned any specific website because of privacy issues. But you can have access to your FTP server using this method.

4. Limit the download speed and the number of connection retries

A single file is okay to download without any restriction. But it can be a headache to leave a bunch of giant files to download in the background. It can reduce your bandwidth, and yes, you face low speed while browsing over the internet.

$ wget --limit-rate=100k --tries=100 https://ftp.gnu.org/gnu/wget/wget-1.5.3.tar.gz
  • limit-rate: Specify the amount of speed is allowed while downloading the file.
  • tries: It is an amount of attempt to take while the connection is lost when the file is downloading from the server.

If you want to read about more 6 commands you can refer to 10 Wget Command example.