当前位置:首页>Linux>一文搞定Linux文件传输命令

一文搞定Linux文件传输命令

  • 2026-09-10 12:09:13
一文搞定Linux文件传输命令

01

写在前面

Linux基础教程已经收官,教程回顾可点击:Linux基础教程。当然,我们后续也会推出更多的Linux与生信相关教程,大家可以点击收藏方便持续关注:生信Linux及服务器使用技巧。
大家如果需要算力/服务器也可以点击这个系列选到自己心仪的设备:
有root权限的共享服务器
生信分析不求人
为实验室准备一份生物信息学不动产
本文就带大家一起学习Linux中常见的文件传输命令,帮助你快速传输大型文件。在学习之前,准备好自己服务器的IP、用户名、端口、密码这些信息啦(你能连接服务器,当然也就知道这些信息)。

02

scp联通的不同的主机传输文件

scp 与 cp 的区别是,cp 用于在 linux 本机下拷贝文件到其他路径。scp 的原理其实是使用 ssh 协议登陆到 linux 服务器,然后传输文件。ssh 协议可以使用用户名和密码登陆Linux,也可以使用用户名和密钥来登陆。

以下的 user,host,port,xx.pem都需要代入具体的值
COPYssh user@host -p port (需要输入密码)ssh user@host -p port -i xx.pem (使用密钥进行认证)# 使用 scp 拷贝文件时使用的命令与 ssh 是类似的。scp -P port user@host:/tmp/xiyou.txt . (将远程主机的 /tmp/xiyou.txt 文件拷贝到本机的当前工作目录,这里"."表示当前目录,需要输入密码)scp -r -P port user@host:/tmp/ . (复制远程主机上的目录到本机的当前工作目录) scp -i xx.pem -P port user@host:/tmp/xiyou.txt . (使用秘钥 xx.pem 的方式认证,不需要输入密码,秘钥需要提前生成)# 将本地的文件拷贝到远程主机上:scp -P port user@host:/tmp xiyou.txt

03

wget用于从网络中下载文件

# 下载链接中的图片 https://mirrors.tuna.tsinghua.edu.cn/static/img/logo-small-dark.png 并存储为 tuna.pngwget -O tuna.png "https://mirrors.tuna.tsinghua.edu.cn/static/img/logo-small-dark.png"ls -la | grep tuna.png# 下载一个文件,不指定文件名wget https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu/gpgls -la | grep gpg# 查看 wget 其他参数的使用方法wget --help# -c 参数支持断点续传,这在传输大文件时十分有用wget -c -O tuna2.png https://mirrors.tuna.tsinghua.edu.cn/static/img/logo-small-dark.png

04

mwget

mwget 是 wget 的升级版,支持多线程,下载速度更快。安装方式如下:

COPY# 安装编译依赖sudo apt updatesudo apt install build-essential -ysudo apt upgrade intltool -ysudo apt install  libssl-dev -y# 编译git clone https://github.com/rayylee/mwget.gitcd mwget./configuresudo make && sudo make install# 查看使用方法mwget --helpmwget https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu/gpg

05

curl通常用来在终端中模拟浏览器访问网站

curl 也可以用来下载文件,不过使用体验不如 wget。

COPY# 使用 curl 下载链接中的文件,并保存为 tuna3.pngcurl -o tuna3.png https://mirrors.tuna.tsinghua.edu.cn/static/img/logo-small-dark.png# 查看 curl 的其他用法curl --help

06

rsync

参考链接:https://www.ruanyifeng.com/blog/2020/08/rsync.html

COPY# 使用 2234 端口,将本地的 source 目录拷贝到远程机的 /destination 目录rsync -av -e 'ssh -p 2234' source/ user@remote_host:/destination

如何联系我们

留一个领取资料、开箱即用的单细胞分析镜像的微信号[Biomamba_zhushou],方便各位随时交流。同时我们也构建了交流群矩阵,欢迎大家入群讨论。
大家可以阅读完这几篇之后添加
给生信入门初学者的小贴士
没有检索,就没有发言权

已有生信基地联系方式的同学无需重复添加

您点的每个赞和在看,我都认真当成了喜欢

最新文章

随机文章