How do I use the wget command?

This article provides a quick overview of the wget command line utility, explaining its core purpose and exploring fundamental examples. By reading further, you will understand how to leverage this tool for downloading files directly from your terminal, handling interrupted downloads, and exploring advanced options for web scraping or mirroring.

Understanding Wget

The wget command is a free, non-interactive network utility used to download files from the web. It supports HTTP, HTTPS, and FTP protocols, as well as retrieval through HTTP proxies. Because it is non-interactive, it can work in the background even if the user has logged off, making it incredibly useful for automating downloads, running scripts, or handling large files over unstable network connections.

Basic Syntax and Usage

Using the tool is straightforward. The basic syntax involves typing the command followed by the URL of the file you wish to download. Executing a simple command with a target URL will retrieve the specified file and save it directly in your current working directory.

If you want to save the downloaded file under a different name, you can use the -O (capital O) flag followed by your desired filename. For downloading multiple files at once, you can place a list of URLs in a plain text file and use the -i flag to instruct the utility to read and download from that list sequentially.

Advanced Downloading Features

One of the most powerful features of this utility is its ability to resume interrupted downloads. If your connection drops halfway through transferring a large file, using the -c flag allows you to continue the download exactly where you left off, rather than starting from scratch and wasting bandwidth.

Additionally, the tool excels at recursive downloading. By using the -r flag, you can download entire websites or specific directories for offline viewing. When combined with mirroring flags, it becomes a staple for archiving web content, creating local backups, or migrating server files.

Further Resources

To master this utility and explore its extensive list of arguments and flags, it is highly recommended to consult community guides and documentation. You can check out this comprehensive resource for the tool to deepen your understanding, discover more complex use cases, and optimize your daily command line operations.