×


Linux wget Command - Explained with Examples

This article covers the wget command which downloads files served with HTTP, HTTPS, or FTP over a network. In fact, Wget is a free GNU command-line utility tool used to download files from the internet. It retrieves files using HTTP, HTTPS, and FTP protocols.



Wget command options includes:

  • -V, --version: Display the version of wget, and exit.
  • -h, --help: Print a help message describing all the wget's command-line options, and exit.
  • -b, --background: Go to background immediately after startup. If no output file is specified via the -o, output is redirected to wget-log.
  • -e command,
  • --execute command: Execute command as if it were a part of the file .wgetrc. A command thus invoked is executed after the commands in .wgetrc, thus taking precedence over them.


How to Check if wget is Installed?

To check, open the terminal window and type in:

$ wget

If the output displays wget command not found you need to download and install the tool manually. Below you will find the installation instructions for Ubuntu/Debian, CentOS, and Windows.

To install wget on Ubuntu or Debian releases, use the command:

$ sudo apt-get install wget

To install wget on CentOS or Fedora, type the following command:

$ sudo yum install wget


How to Install wget on Windows ?

  • Download wget for Windows and install the package.
  • Add the wget bin path to environment variables (optional). Configuring this removes the need for full paths, and makes it a lot easier to run wget from the command prompt:
  • Open the Start menu and search for "environment".
  • Select Edit the system environment variables.
  • Select the Advanced tab and click the Environment Variables button.
  • Select the Path variable under System Variables.
  • Click Edit.
  • In the Variable value field add the path to the wget bin directory preceded by a semicolon (;). If installed in the default path, add C:Program Files (x86)GnuWin32bin.
  • Open the command prompt (cmd.exe) and start running wget commands.

Wget Command Examples on Linux Command Line

This article covers different wget command for different operations along with options. Wget is a command line utility in linux to download files from the internet. It provides many features such as downloading multiple files, resuming stopped downloads, limiting the bandwidth, downloading in the background and can be used for taking mirrors of the site. Wget supports HTTP, HTTPS and FTP protocol to connect server and download files.

You can learn more about Wget visit the GNU wget Manual page.


How to Install wget on Ubuntu | Debian ?

If your operating system is Ubuntu, or another Debian-based Linux distribution which uses APT for package management, you can install wget with apt-get:

$ sudo apt-get install wget