How to use the wget command line tool?

This article provides a comprehensive overview of wget, a widely used command line utility for downloading files directly from the internet. In the following sections, we will cover what this tool is, its core features, and practical examples of its most common commands to help you streamline your file retrieval and automation tasks.

What is the wget utility?

The name wget is derived from “World Wide Web” and “get.” It is a free, open-source software package belonging to the GNU Project that is used for retrieving files via HTTP, HTTPS, FTP, and FTPS protocols. One of its strongest advantages is that it is strictly non-interactive. This means it can function independently in the background without requiring active user input, making it highly effective for automating routine downloads through shell scripts or cron jobs.

Core Features

This utility is designed to be highly robust, particularly when dealing with unstable or slow network connections. Here are a few reasons why it remains a fundamental tool for system administrators and developers:

Common Commands and Syntax

Using the tool is straightforward. The most basic operation involves invoking the command followed by the target URL.

Downloading a Single File To pull a file down into your current working directory, simply provide the link: wget https://example.com/file.zip

Resuming an Interrupted Download If a large download is disconnected, you can use the -c (continue) flag to pick up exactly where the transfer left off, saving time and bandwidth: wget -c https://example.com/largefile.iso

Downloading in the Background For massive files that take a significant amount of time, the -b (background) flag pushes the process to the background, freeing up your terminal for other tasks: wget -b https://example.com/massivefile.tar.gz

Limiting Download Speed If you are on a shared network and want to avoid hoarding bandwidth, you can throttle the download speed using the --limit-rate option: wget --limit-rate=500k https://example.com/file.mp4

Mastering terminal utilities often requires testing out different flags and understanding edge cases. If you are looking to deepen your knowledge of this specific utility and explore more advanced configurations, check out https://salivity.github.io/wget a resource for this tool. It serves as an excellent reference guide for building out your command line skill set.