Linux入门 7_Linux系统中的文件传输

2021/7/23 7:09:24

本文主要是介绍Linux入门 7_Linux系统中的文件传输,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

文件操作

一、文件传输与下载

1.scp 下载与上传

进行文件传输时,不检测文件或者目录是否已经存在,并且无法进行数据压缩。

scp 把本地文件复制到远程主机 (上传)

scp westos root@172.25.254.173:/root/Desktop
scp -r westosdir root@172.25.254.173:/root/Desktop 		## -r 表示复制目录
scp -q westos root@172.25.254.173:/root/Desktop		 ## -q 传输文件时不显示进度

scp 把远程文件复制到本地(下载)

scp root@172.25.254.173:/root/Desktop/westos_rhel8 /root/Desktop

time scp root@192.168.158.128:/root/Desktop/file /root/Desktop/file    #时间显示

2.rsync

rsync的用法

rsync 文件 远程用户@远程主机ip:远程主机目录
rsync 远程用户@远程主机ip:远程主机目录 文件路径

 rsync -[options] resourcefile user@serverip:dir #上传
 rsync -[options] user@serverip:resourcedir file #下载
options功能
-a压缩传输
-c检测目标是否已存在
-r复制目录
-l复制链接
-p复制权限
-t复制时间戳
-o复制拥有者
-g复制拥有组
-D复制设备文件

二、文档的打包与解压缩

1.打包

 tar -[options] xxx.tar dir|command
options功能
c创建
f指定文件名称
x解档
v现实过程
t查看
r向归档文件中添加文件
–get解档指定文件
–delete删除指定文件
-C指定解档路径
-P在打包或解包时保留绝对路径符号 “/”

在这里插入图片描述

2.文件压缩

zip -r mnt.tar.zip mnt.tat		#zip格式压缩文件
unzip mnt.tar.zip				#zip格式解压文件
gzip mnt.tar	#gizp压缩文件
ugzip mnt.tar	#gzip解压文件
bzip2 mnt.tar 				#bzip2格式压缩
bunzip2 etc.tar.bz2 		#bzip2格式解压缩
xz mnt.tar				#xz格式压缩
unxz mnt.tar.xz 		#xz格式解压缩

3.文件打包同时压缩

 tar zcf etc.tar.gz /etc				 #gzip格式压缩
 tar zxf etc.tar.gz						 #gzip格式解压缩
 tar jcf etc.tar.bz2 /etc 				#bzip2格式压缩
 tar jxf etc.tar.bz2 					#bzip2格式解压缩
tar Jcf etc.tar.xz /etc					#xz格式压缩
tar Jxf etc.tar.xz						#xz格式解压缩

在这里插入图片描述



这篇关于Linux入门 7_Linux系统中的文件传输的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程