- Posted on
- • Software
wget: Command-line file downloader
- Author
-
-
- User
- Linux Bash
- Posts by this author
- Posts by this author
-
Exploring wget
: Your Essential Command-line File Downloader
In the vast toolbox of the Linux command line, wget
stands out as a versatile and robust tool for downloading files from the web. It's cherished among system administrators, developers, and even casual users for its simplicity and powerful capabilities, including downloading files from FTP, HTTP, and HTTPS protocols, as well as recursively downloading websites. In this blog, we'll dive into what wget
is, how to install it across various Linux distributions, and share some practical examples to get you started.
What is wget
?
wget
is a non-interactive network downloader which supports HTTP, HTTPS, and FTP protocols and can handle the retrieval of large files and recursive downloads efficiently. It comes with numerous features allowing users to download data in the background, resume downloads, limit the bandwidth used for downloads, and much more.
Installing wget
Before you can harness the power of wget
, you need to ensure it's installed on your system. The installation process varies depending on the Linux distribution you are using. Here’s how to install wget
using different package managers:
Debian and Ubuntu (Using apt
)
- Open your terminal.
- Update your package list to ensure you get the latest version of the software:
bash sudo apt update
- Install
wget
usingapt
:bash sudo apt install wget
Fedora (Using dnf
)
- Open your terminal.
- Install
wget
usingdnf
:bash sudo dnf install wget
openSUSE (Using zypper
)
- Open your terminal.
- Update your package list:
bash sudo zypper refresh
- Install
wget
usingzypper
:bash sudo zypper install wget
After installation, you can verify that wget
is installed and check its version by typing:
wget --version
Basic Usage of wget
To start using wget
, you only need to know a few basic commands. Here's how to download a file:
wget [URL]
This command will download the file from the specified URL to the current directory.
Example: Downloading a File
Say you want to download a sample file from Example.com:
wget http://example.com/sample.zip
The file sample.zip
will be downloaded to the current working directory.
Downloading Files to a Specific Directory
To specify a directory for the downloaded files, use the -P
or --directory-prefix
option:
wget -P /path/to/directory [URL]
For example:
wget -P ~/Downloads http://example.com/sample.zip
Resuming a Partially Downloaded File
If your download gets interrupted, you can resume it using the -c
or --continue
option:
wget -c [URL]
Tips and Tricks
Recursive Download: You can download an entire website or parts of it for offline access using:
wget -r [URL]
Limiting Bandwidth: If you don’t want
wget
to hog all your bandwidth, use the--limit-rate
option:wget --limit-rate=200k [URL]
Downloading in the Background: If you have a large file that needs downloading but you want to free up the terminal:
wget -b [URL]
wget
is an exceptionally powerful tool when you start to explore its capabilities. This introduction just scratches the surface of what you can achieve with this indispensable command-line utility.
Whether you're a seasoned system administrator or just starting your Linux journey, wget
is a tool that's definitely worth exploring. Happy downloading!