Linux wget 命令完全指南
文件下载神器
wget 是什么?
wget 是 Linux/Unix 系统中最常用的命令行下载工具,支持 HTTP、HTTPS、FTP 等多种协议。
基础用法
# 下载单个文件 wget https://example.com/file.zip # 下载并重命名 wget -O myfile.zip https://example.com/file.zip # 后台下载 wget -b https://example.com/largefile.iso
常用选项
# -c 断点续传(继续未完成的下载) wget -c https://example.com/largefile.zip # -r 递归下载整个网站 wget -r https://example.com/ # --limit-rate 限速(避免占满带宽) wget --limit-rate=1m https://example.com/largefile.zip # -q 安静模式(不显示输出) wget -q https://example.com/file.zip
实战案例
# 下载整个网站(离线浏览) wget -r -p -k -E https://example.com/ # 跳过 SSL 证书验证 wget --no-check-certificate https://example.com/secure.zip # 下载多个文件(从文件列表) wget -i filelist.txt # 使用代理下载 wget -e https_proxy=http://proxy:8080 https://example.com/file.zip
💡 小贴士
curl 适合 API 调用和单文件下载,wget 适合递归下载整个网站。两者配合使用效果更佳!