Introduction
wget is a command-line tool used for downloading files from the internet. In Linux, wget allows you to download files, websites, or even entire directories with ease. It is a powerful and versatile utility that is widely used by system administrators and developers for various tasks.
Basic Syntax
The basic syntax for using wget is as follows:
1
wget [options] [URL]
Some common options include -P to specify the directory where the downloaded file should be saved, -r for recursive downloading, -np to exclude parent directories, and -c to resume a partially downloaded file.
Downloading Files
To download a single file using wget, simply provide the URL of the file as an argument:
1
wget http://example.com/file.txt
This will download the file.txt from the specified URL and save it in the current directory.
Downloading Websites
wget can also be used to download entire websites for offline viewing. Use the -r and -np options for recursive downloading and to exclude parent directories:
1
wget -r -np http://example.com
This command will download all the files from the example.com website and save them in a directory named after the website.
Downloading with Authentication
If you need to download a file that requires authentication, you can use the –user and –password options to provide your credentials:
1
wget --user=username --password=password http://example.com/file.txt
This will allow wget to access the file with the provided credentials.
Applicable Versions
wget is a standard command-line tool that is available on most Linux distributions and Unix-like operating systems. It is commonly used in shell scripts and automated tasks to download files from the internet.
In conclusion, wget is a versatile tool that is essential for downloading files in a Linux environment. Its rich set of options and ease of use make it a valuable asset for any user. Whether you need to download a single file or an entire website, wget has got you covered.