How To Wget In Linux

Linux is a powerful open-source operating system that offers a wide array of functionalities and tools. One of these is the ability to download files directly from the command line using the wget command. This guide will show you how to effectively use wget in Linux.

What is wget?

Wget is a free utility that non-interactively downloads files from the web. It supports HTTP, HTTPS, and FTP protocols, as well as retrieval through HTTP proxies. This command ensures that large files or mirrored directories will continue to be downloaded from the point they left off if the download is interrupted, providing reliable downloads.

How to Install wget?

Wget comes pre-installed in most Linux distributions. In case it isn’t available, you can install it using the package manager for your distro. For Ubuntu or Debian-based distributions, you can use the apt-get command:

    sudo apt-get install wget
    

For Fedora or CentOS, use the yum command:

    sudo yum install wget
    

Basic Usage of wget

The most basic usage of wget is to download a file from a specified URL. Here’s an example:

    wget https://example.com/file.zip
    

Advanced Usage of wget

Wget also offers many options that let you customize your download. Some of the most commonly used options include:

  • -O: This option allows you to specify the name of the file in which to save the download. For example:
    wget -O myFile.zip https://example.com/file.zip
    
  • -P: This option allows you to specify the directory to which to save the file. For example:
    wget -P /path/to/directory https://example.com/file.zip
    
  • -c: This option allows you to continue getting a partially downloaded file. This is useful for resuming interrupted downloads. For example:
    wget -c https://example.com/file.zip
    

There are many other options that you can use with wget. To see a complete list of options, you can check out the man page by typing man wget in the terminal.

Conclusion

Wget is a powerful tool in Linux that allows you to download files from the web directly from the command line. It offers a plethora of options that let you customize your download, making it a versatile tool that caters to a variety of needs.