wget命令
基本用法
wget -O http://example.com/file.zip
-O 参数表示将文件保存为原始文件名。
如果需要指定文件名,可以使用 -o 参数:
wget -o custom_name.zip http://example.com/file.zip
-P :指定下载文件的保存路径。
wget -P /path/to/directory https://example.com/file.zip
-c:断点续传,支持从上次中断的地方继续下载。
wget -c https://example.com/largefile.iso
-b:后台下载,下载过程在后台进行。
wget -b https://example.com/file.zip
-q:静默模式,不显示下载过程。
wget -q https://example.com/file.zip
curl命令
基本用法
curl -O http://example.com/file.zip
-O 参数表示将文件保存为原始文件名。
如果需要指定文件名,可以使用 -o 参数:
curl -o custom_name.zip http://example.com/file.zip
下载并显示进度
curl -O -# http://example.com/file.zip
-# 参数用于显示进度条。
-C -:断点续传。
curl -C - -O https://example.com/largefile.iso
aria2:是一个轻量级的多协议、多线程命令行下载工具。它支持 HTTP/HTTPS、FTP、BitTorrent 等协议,并且可以通过多线程加速下载。
sudo yum install aria2 -y
基本用法
aria2c http://example.com/file.zip
多线程下载
aria2 默认支持多线程下载,可以通过 -x 参数指定线程数:
aria2c -x 5 http://example.com/file.zip
-x 5 表示使用 5 个线程进行下载。
-d :指定下载文件的保存路径。
aria2c -d /path/to/directory https://example.com/file.zip
-o :指定下载文件的保存名称。
aria2c -o myfile.zip https://example.com/file.zip
-s :指定同时下载的线程数。
aria2c -s 10 https://example.com/largefile.iso
-c:断点续传。
aria2c -c https://example.com/largefile.iso
axel:轻量级,多线程下载。
sudo yum install axel -y
基本用法
axel http://example.com/file.zip
多线程下载
可以通过 -n 参数指定线程数:
axel -n 5 http://example.com/file.zip
-n 5 表示使用 5 个线程进行下载。
o :指定下载文件的保存名称。
axel -o myfile.zip https://example.com/file.zip
-a:显示进度条。
axel -a https://example.com/file.zip
ftp:适合从 FTP 服务器下载文件。
ftp ftp.example.com
在 ftp 交互模式下:
user :登录 FTP 服务器。
cd :切换目录。
get :下载文件。
bye:退出 FTP 会话。
sftp 是一个基于 SSH 的文件传输工具,支持安全的文件传输。
sftp user@remote_host
在 sftp 交互模式下:
cd :切换目录。
get :下载文件。
bye:退出 SFTP 会话。
scp:安全地从远程服务器下载文件。
scp user@remote_host:/path/to/file.zip /path/to/local/directory
常用选项:
-r:递归拷贝目录。
-P :指定远程主机的 SSH 端口。
-v:显示详细信息。
rsync:适合同步文件和目录。
语法:
rsync <source> <destination>
rsync -avz user@remote_host:/path/to/file.zip /path/to/local/directory
常用选项:
-a:归档模式,递归同步文件并保留文件属性。
-v:显示详细信息。
-z:压缩文件数据在传输过程中。
-P:显示进度条。