Linux Comm Wget
[ Linux Command Encyclopedia](#)
* * *
## What is wget Command?
wget is a powerful non-interactive network download tool in Linux system, named from the combination of "World Wide Web" and "get". It supports downloading files through HTTP, HTTPS and FTP protocols, with practical features such as breakpoint continuation and recursive download.
Different from browser download or curl command, the main features of wget are:
* **Non-interactive**: can run in the background without user intervention
* **Strong stability**: can automatically retry when network fluctuates
* **Feature-rich**: supports multiple download scenarios and advanced options
* * *
## wget Basic Syntax
wget
### Simplest Download Example
## Example
wget https://example.com/file.zip
This command will download the file from the specified URL to the current directory.
* * *
## Detailed Explanation of Common Options
### Download Control Options
| Option | Description | Example |
| --- | --- | --- |
| `-O ` | Specify save filename | `wget -O myfile.zip https://example.com/file.zip` |
| `-P ` | Specify download directory | `wget -P ~/downloads https://example.com/file.zip` |
| `-c` | Breakpoint continuation | `wget -c https://example.com/bigfile.iso` |
| `-b` | Background download | `wget -b https://example.com/largefile.mp4` |
### Connection Settings Options
| Option | Description | Example |
| --- | --- | --- |
| `--limit-rate=` | Rate-limited download | `wget --limit-rate=200k https://example.com/file.iso` |
| `-t ` | Set retry times | `wget -t 5 https://example.com/unstable.file` |
| `--timeout=` | Set timeout | `wget --timeout=30 https://example.com/slow.file` |
### Recursive Download Options
| Option | Description | Example |
| --- | --- | --- |
| `-r` | Recursive download | `wget -r https://example.com/directory/` |
| `-l ` | Set recursive depth | `wget -r -l 2 https://example.com/` |
| `-np` | Do not ascend to parent directory | `wget -r -np https://example.com/path/` |
* * *
## Practical Examples and Application Scenarios
### Example 1: Download Single File and Rename
## Example
wget -O linux_distro.iso https://example.com/ubuntu-22.04.iso
**Description**:
* Download Ubuntu 22.04 image from specified URL
* Use `-O` option to save file with custom name `linux_distro.iso`
### Example 2: Rate-limited Download of Large File
## Example
wget --limit-rate=500k -c https://example.com/large_video.mp4
**Description**:
* `--limit-rate=500k` limits download speed to 500KB/s
* `-c` supports breakpoint continuation, can continue download after network interruption
### Example 3: Recursive Download of Entire Website
## Example
wget -r -l 5 --convert-links --wait=2 https://example-site.com
**Description**:
* `-r` enables recursive download
* `-l 5` sets maximum recursive depth to 5 levels
* `--convert-links` converts links suitable for local browsing
* `--wait=2` waits 2 seconds between downloads to reduce server load
* * *
## Advanced Tips and Notes
### 1. Batch Download Files
Create a text file `urls.txt` containing multiple URLs, then use:
## Example
wget -i urls.txt
### 2. Download FTP Resources
## Example
wget ftp://username:password@ftp.example.com/file.zip
**Note**: Password will be displayed in command history, it is recommended to use `--ftp-user` and `--ftp-password` options separately.
### 3. Common Problem Solutions
**Problem 1**: Certificate error
## Example
wget --no-check-certificate https://example.com
**Problem 2**: Download rejected (403 Forbidden)
## Example
wget --user-agent="Mozilla/5.0" https://example.com
* * *
## Visualization: wget Workflow
!(#)
* * *
## Practice Exercises
1. Try downloading Linux kernel source code:
wget https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.5.5.tar.xz
2. Use breakpoint continuation to download a large file, reconnect to continue after interruption
3. Create a text file containing multiple image URLs, use batch download to get all images
* * *
## Summary
wget is an indispensable download tool in Linux system. Through this article you have learned:
* Basic syntax and common options of wget
* Download methods in various practical application scenarios
* Advanced tips and problem solutions
* Implementation of recursive download and batch download
Mastering the wget command will greatly improve your efficiency in handling network resources under Linux environment.
[ Linux Command Encyclopedia](#)
YouTip