wget 是 Linux 系統內建的非互動式網路下載工具,支援 HTTP/HTTPS/FTP、斷點續傳、遞歸鏡像、頻寬限制、後台執行等強大功能。本文整理 11 個實戰場景與參數詳解,涵蓋從單檔下載到整站鏡像的完整技巧。
| 參數 | 長參數 | 說明 |
|---|---|---|
-c | --continue | 斷點續傳 |
-b | --background | 後台執行 |
--limit-rate | 限制下載速率(如 100k, 2M) | |
-i | --input-file | 從檔案讀取 URL 列表 |
-t | --tries | 重試次數(預設 20) |
-o | --output-file | 記錄輸出到檔案 |
-Q | --quota | 總下載配額 |
--mirror | 鏡像模式(遞歸+時間戳+無限深度) | |
-p | --page-requisites | 下載頁面完整資源(CSS/JS/圖片) |
--convert-links | 轉換連結為本地相對路徑 | |
-P | --directory-prefix | 指定儲存目錄 |
--reject | 拒絕特定副檔名(如 png) | |
--user/--password | FTP/HTTP 基本認證 |
$ wget https://mirror.example.com/CentOS-7-x86_64-DVD.iso
$ wget -c https://mirror.example.com/CentOS-7-x86_64-DVD.iso

$ wget -b https://mirror.example.com/CentOS-7-x86_64-DVD.iso
# 輸出寫入 wget-log,可用 tail -f wget-log 監看
$ wget --limit-rate=100k https://mirror.example.com/large.iso
$ cat download-list.txt
url1
url2
url3
$ wget -i download-list.txt
$ wget --tries=75 https://mirror.example.com/large.iso
$ wget -o download.log https://mirror.example.com/large.iso
$ wget --mirror -p --convert-links -P ./local-copy https://example.com
$ wget --reject=png https://example.com
$ wget -Q10m -i download-list.txt
# 超過 10MB 停止(不影響單檔下載完成)
$ wget --ftp-user=user --ftp-password=pass ftp://example.com/file.zip
# 或 URL 內嵌認證(不安全,會殘留於歷史)
$ wget ftp://user:pass@example.com/file.zip
ps aux),建議寫入 ~/.netrc 或 ~/.wgetrc 並 chmod 600--ask-password 互動式輸入cron 執行 wget --limit-rate=500k -i nightly.txtwget 退出碼非 0 時自動 -c 重試wget -m -np -nH --cut-dirs=2 -R "index.html*" https://mirror.example.com/centos/