Wget Cheatsheet
#
wget
is a command-line utility for downloading files from the web. It supports various protocols and options.
Basic Commands
#
Command/Option | Example | Description |
---|
wget <url> | wget http://example.com/file.txt | Download the file from the URL |
wget -O <file> <url> | wget -O myfile.txt http://example.com/file.txt | Save the file to a specific location |
wget -P <dir> <url> | wget -P /path/to/dir http://example.com/file.txt | Download the file and save it to a directory |
Download Options
#
Command/Option | Example | Description |
---|
wget -r <url> | wget -r http://example.com/ | Download the entire site recursively |
wget -np <url> | wget -np http://example.com/dir/ | Avoid ascending to the parent directory |
wget -l <depth> <url> | wget -l 2 http://example.com/ | Set recursion depth (e.g., 2 levels deep) |
wget -nc <url> | wget -nc http://example.com/file.txt | Do not download files that already exist |
wget -N <url> | wget -N http://example.com/file.txt | Download only if the remote file is newer |
Authentication
#
Command/Option | Example | Description |
---|
wget --user=<user> --password=<pass> <url> | wget --user=user --password=pass http://example.com/ | Use HTTP basic authentication |
wget --auth-no-challenge --user=<user> --password=<pass> <url> | wget --auth-no-challenge --user=user --password=pass http://example.com/ | Use HTTP authentication without challenge |
Handling Output
#
Command/Option | Example | Description |
---|
wget -q <url> | wget -q http://example.com/ | Quiet mode, no output |
wget -v <url> | wget -v http://example.com/ | Verbose mode, detailed output |
wget --append-output <file> <url> | wget --append-output log.txt http://example.com/ | Append output to a log file |
Download Resumption
#
Command/Option | Example | Description |
---|
wget -c <url> | wget -c http://example.com/file.txt | Continue a partially downloaded file |
Proxy Settings
#
Command/Option | Example | Description |
---|
wget -e use_proxy=yes -e http_proxy=<proxy> <url> | wget -e use_proxy=yes -e http_proxy=http://proxy.example.com:8080 http://example.com/ | Use a proxy for the download |
Additional Options
#
Command/Option | Example | Description |
---|
wget --limit-rate=<rate> <url> | wget --limit-rate=200k http://example.com/file.txt | Limit download rate (e.g., 200 KB/s) |
wget --timeout=<seconds> <url> | wget --timeout=30 http://example.com/ | Set connection timeout in seconds |
This cheatsheet provides essential wget
commands and options for downloading files from the web.