The wget
command is a useful tool in Linux and Unix-like operating systems for downloading files from the internet. It allows you to retrieve files using various protocols such as HTTP, HTTPS, and FTP.
The basic syntax of the wget
command is as follows:
wget [options] [URL]
Here, [options]
represents the various flags and parameters you can use with the command, and [URL]
denotes the web address or file location you want to download.
Some commonly used options with wget
include:
-O
: Specifies the output filename for the downloaded file.-P
: Specifies the directory path where the downloaded file should be saved.-c
: Resumes a previously interrupted download.-r
: Downloads recursively, following links and retrieving files from subdirectories.-np
: Prevents downloading files from parent directories when used with-r
.-N
: Downloads only if the remote file is newer than the local version.-q
: Runs in quiet mode, suppressing most of the output.--user
: Specifies a username for authentication.--password
: Specifies a password for authentication.
To use the wget
command, open a terminal and enter the command followed by the desired options and the URL. Here are a few examples:
- Download a file and save it with a specific filename:
wget -O filename.extension URL
- Download a file and save it to a specific directory:
wget -P /path/to/directory URL
- Resume a previously interrupted download:
wget -c URL
- Download a complete website recursively:
wget -r -np URL
These are just a few examples, and there are many more options and use cases for the wget
command. To explore additional options and information, you can refer to the wget
command’s manual page by typing man wget
in the terminal.