unit8、linux中用scp、rsync下载和传送文件,解压的的相关了解

本文介绍了Linux中使用scp和rsync进行文件下载和上传的操作,包括scp的简单示例和rsync的常用参数。同时,详细讲解了tar命令在文件整合与压缩方面的应用,涵盖了gzip、bzip2、xz等压缩格式的使用方法。
摘要由CSDN通过智能技术生成

#################scp用来下载和上传东西
server200
client100
server中:

[root@server Desktop]# touch file1                    ##建立file1
[root@server Desktop]# ls
file1
[root@server Desktop]# pwd                            ##查看路径
/root/Desktop


client100:

[root@desktop Desktop]# scp root@172.25.254.200:/root/Desktop/file1 /root/Desktop   ##将其现在到桌面
root@172.25.254.200's password: 
file1                                                                            100%    0     0.0KB/s   00:00    
[root@desktop Desktop]# ls                             ####查看下载的file1
file  file1  waring_check  westos  westos1
[root@desktop Desktop]# 


###刚才是下载,现在是上传
client100:

[root@desktop Desktop]# scp file root@172.25.254.200:/root/Desktop          ##将文件上传到对面桌面
root@172.25.254.200's password: 
file                                                                             100%    0     0.0KB/s   00:00    
[root@desktop Desktop]# 

server200:

[root@server Desktop]# ls                                                 ##查看已经到达
file  file1
[root@server Desktop]# 


#################rsync也可以实现上传与下载
###参数没有举例,如需要可以字行的加
-r ##同步目录
-p ##同步权限
-o ##同步文件所有人
-g ##同步文件所有组
-l ##同步链接
-D ##同步设备文件
-t ##时间同步
##把所有参数写上:rsync -rpogtl /dev/pts root@172.25.254.200:/mnt 表示同步目录权限和文件拥有着,拥有组,时间和连接client100:

[root@desktop mnt]# touch file{1..5}                                        ##建立文件
[root@desktop mnt]# ls
file1  file2  file3  file4  file5
[root@desktop mnt]# rsync * root@172.25.254.200:/mnt                         ##将文件上传
root@172.25.254.200's password: 


server200

[root@server Desktop]# cd /mnt                                           ##在server中查看
[root@server mnt]# ls
file  file1  file2  file3  file4  file5  off


##rsync实现下载
server200:

[root@server mnt]# touch file7                                    ##建立文件
[root@server mnt]# ls
file  file1  file2  file3  file4  file5  file6  file7  off

client100:

[root@desktop mnt]# rsync root@172.25.254.200:/mnt/file7 /mnt      ##进行下载
root@172.25.254.200's password: 
[root@desktop mnt]# ls
file1  file2  file3  file4  file5  file6  file7

##############tar文件的整合与压缩
tar cf etc.tar /etc
tar cf etc.tar /etctar tf etc.tar
tar cf etc.tar /etctar tf etc.tartar f etc.tar --get file
-c ##创建
-x ##解档
-v ##显示过程
-f ##指定归档文件名称
-t ##查看归档文件内容
-r ##添加文件到归档中
–get ##解档指定文件
–delete ##删除归档中的指定文件
-C ##指定解档目录
######################压缩过程
zip
zip -r xxx.tar.zip xxx.tar
unzip xxx.tar.zip
gz
gzip xxx.tar
gunzip xxx.tar.gz
====
tar zcf xxx.tar.gz /xxx
tar zxf xxx.tar.gz
bz2
bzip2 xxx.tar
bunzip2 xxx.tar.bz2
===
tar jcf xxx.tar.bz2 /xxxx
tar jxf xxx.tar.bz2
xz
xz xxx.tar
unxz xxx.tar.xz
====
tar Jcf xxx.tar.xz /xxx
tar Jxf xxx.tar.xz

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值