Wget is a Linux command-line tool used for downloading files from the internet. It is a non-interactive tool that can download files in the background, allowing you to perform other tasks while the download is in progress. Wget supports HTTP, HTTPS, and FTP protocols and can be used to download files from both public and password-protected websites.
The basic syntax for using wget is as follows:
wget [options] [URL]
To download a file using wget, simply provide the URL of the file you want to download. For example, to download a file named “example.zip” from a website, you would use the following command:
By default, wget will download the file to the current working directory. You can specify a different directory by using the
-P option followed by the directory path. For example, to download the file to a directory named “downloads”, you would use the following command:
wget -P /path/to/downloads https://example.com/example.zip
Wget can also be used to download multiple files at once. To do this, create a text file containing the URLs of the files you want to download, with each URL on a separate line. Then, use the
-i option followed by the path to the text file. For example, to download all the files listed in a file named “urls.txt”, you would use the following command:
wget -i /path/to/urls.txt
Wget also supports resuming interrupted downloads. To resume a download, use the
-c option followed by the URL of the file you want to resume. For example, to resume a download of a file named “example.zip”, you would use the following command:
wget -c https://example.com/example.zip
The following table lists the available options for the wget command:
||Specifies the directory where downloaded files will be saved|
||Resumes a partially downloaded file|
||Downloads files listed in a text file|
||Downloads files recursively|
||Disables downloading files from parent directories|
||Downloads only files that are newer than existing files|
||Runs wget in quiet mode|
||Specifies the name of the downloaded file|
||Specifies the user agent string to use|
||Specifies the number of retries if a download fails|
||Specifies the timeout for a download|
||Runs wget in the background|
||Appends output to a log file|
- If you receive an error message indicating that the download failed, try using the
-toption to increase the number of retries. For example,
wget -t 10 https://example.com/example.zip.
- If you receive an error message indicating that the download timed out, try using the
-Toption to increase the timeout period. For example,
wget -T 60 https://example.com/example.zip.
- If you are having trouble downloading a file from a password-protected website, try using the
--passwordoptions to provide your login credentials. For example,
wget --user=username --password=password https://example.com/example.zip.
- Wget is a powerful tool that can be used to download large files and entire websites. However, be aware that downloading large amounts of data can consume a lot of bandwidth and may be subject to restrictions by your internet service provider.
- Always ensure that you have the legal right to download any files you are downloading with wget. Some websites may have terms of service or copyright restrictions that prohibit downloading their content without permission.