# Linux下wget命令詳解
## 1. wget命令概述
### 1.1 wget簡介
wget是GNU項目開發的一個非交互式網絡下載工具,全稱為"Web Get",是Linux/Unix系統中最常用的命令行下載工具之一。它支持HTTP、HTTPS和FTP協議,能夠遞歸下載網站內容,具有斷點續傳、帶寬控制、鏡像網站等強大功能。
wget的主要特點包括:
- 非交互式操作:可以在后臺運行
- 支持斷點續傳
- 支持遞歸下載
- 支持代理服務器
- 支持SSL/TLS安全下載
- 支持限速下載
- 支持鏡像整個網站
### 1.2 wget的歷史與發展
wget最初由Hrvoje Nik?i?于1996年開發,后被納入GNU項目。經過20多年的發展,wget已成為Linux系統默認安裝的標準工具之一,幾乎所有Linux發行版都預裝了wget。
## 2. wget安裝與基本使用
### 2.1 安裝wget
大多數Linux發行版已經預裝了wget。如果沒有安裝,可以使用以下命令安裝:
```bash
# Debian/Ubuntu
sudo apt-get install wget
# CentOS/RHEL
sudo yum install wget
# Fedora
sudo dnf install wget
# Arch Linux
sudo pacman -S wget
wget的基本語法格式為:
wget [選項] [URL]
下載單個文件:
wget https://example.com/file.zip
wget -c https://example.com/large-file.iso
wget -b https://example.com/large-file.iso
wget --limit-rate=200k https://example.com/large-file.iso
wget -q https://example.com/file.txt
wget -o download.log https://example.com/file.txt
wget -a download.log https://example.com/file.txt
wget -P /path/to/directory https://example.com/file.txt
wget -x https://example.com/path/to/file.txt
wget --http-user=username --http-password=password https://example.com/protected/file.txt
wget --user-agent="Mozilla/5.0" https://example.com
wget --ftp-user=anonymous --ftp-password=user@example.com ftp://example.com/file.txt
wget --passive-ftp ftp://example.com/file.txt
wget -r https://example.com
wget -r -l 2 https://example.com
wget -r -np https://example.com/path/
wget -m https://example.com
wget -mk https://example.com
wget -N https://example.com/file.txt
wget --no-use-server-timestamps https://example.com/file.txt
wget --tries=10 https://example.com/unstable-file.txt
wget --tries=inf https://example.com/unstable-file.txt
wget --proxy=on http://example.com
wget -e use_proxy=yes -e http_proxy=10.0.0.1:8080 http://example.com
wget -i url-list.txt
wget https://example.com/files/file{1..10}.jpg
wget --quota=100m https://example.com/large-files/
wget -r -A.jpg,.png https://example.com/images/
wget -r -R.html https://example.com
wget --mirror --convert-links --adjust-extension --page-requisites --no-parent https://example.com
wget -mkEpnp https://example.com
wget -r ftp://example.com/pub/
wget -nd -r ftp://example.com/pub/
wget --load-cookies cookies.txt https://example.com/members-only/
wget --header="Accept: text/html" --user-agent="Mozilla/5.0" https://example.com
wget --mirror --convert-links --adjust-extension --page-requisites --no-parent https://example.com
wget https://www.youtube.com/watch?v=VIDEO_ID
wget -r -l1 -A.pdf https://example.com/documents/
while true; do wget -N https://example.com/updated-file.txt; sleep 3600; done
wget -q -O - https://example.com/archive.tar.gz | tar xz
# 設置默認重試次數
tries = 10
# 設置默認限速
limit_rate = 100k
# 使用被動FTP
passive_ftp = on
wget --no-check-certificate https://example.com
wget --timeout=30 https://example.com
wget --max-redirect=5 https://example.com
wget -c --tries=inf https://example.com/large-file.iso
wget是Linux系統中最強大、最靈活的命令行下載工具之一。通過本文的學習,您應該已經掌握了wget的基本用法和高級技巧,能夠利用wget完成各種復雜的下載任務。
無論是簡單的文件下載,還是復雜的網站鏡像,wget都能勝任。結合腳本編程,wget可以自動化完成許多重復性的下載工作,大大提高工作效率。
”`
注意:由于篇幅限制,這里提供的是文章的大綱和主要內容框架。要擴展到11400字,需要在每個章節中添加更多詳細說明、示例、使用場景、注意事項等內容。您可以根據這個框架進一步擴展每個部分的內容。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。