How to use the wget command line tool?
This article provides a comprehensive overview of wget,
a robust and non-interactive command-line utility used for downloading
files from the internet. We will cover its primary functions, basic
syntax, essential command flags, and provide practical examples to help
you seamlessly integrate this tool into your daily workflow.
Understanding wget
The wget command is a free software package for
retrieving files using HTTP, HTTPS, FTP, and FTPS, the most widely used
Internet protocols. Its non-interactive nature means it can work in the
background while the user is not logged on, making it perfect for
automating downloads via scripts or cron jobs. It is known for its
reliability, especially in handling slow or unstable network
connections, as it will continually retry downloading a file until it is
fully retrieved.
Basic Syntax
The standard syntax for the tool is straightforward. You simply invoke the command followed by the options you wish to use and the URL of the file.
wget [option] [URL]
If you run the command without any options, it will simply download the file specified by the URL into your current working directory.
Essential Commands and Flags
To truly unlock the power of this utility, you should become familiar with its most common flags. Here are some of the most useful options:
- Save as a different name (
-O): By default, the file is saved with its original name. Using the-O(capital O) flag allows you to specify a new filename. - Resume a download (
-c): If a download is interrupted due to a dropped connection or system reboot, the-cflag allows you to resume the download exactly where it left off, rather than starting from scratch. - Download in the background (
-b): For massive files, you can use the-bflag to send the download process to the background, freeing up your terminal for other tasks. - Limit download speed (
--limit-rate): If you are on a shared network and do not want to consume all available bandwidth, you can cap the download speed (for example,--limit-rate=1mcaps the speed at 1 megabyte per second). - Recursive download (
-r): This flag is used to download an entire website or directory structure, which is incredibly useful for creating local backups of web pages for offline viewing.
Further Learning and Resources
Mastering terminal utilities takes practice and reliable documentation. For an excellent resource and further reading on this specific tool, you can visit https://salivity.github.io/wget to expand your knowledge, explore more advanced configurations, and view detailed examples of the tool in action.