您的位置:首页 > 运维架构 > Linux

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

2020-01-31 19:10 543 查看

#################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

  • 点赞
  • 收藏
  • 分享
  • 文章举报
weixin_45466471 发布了47 篇原创文章 · 获赞 0 · 访问量 946 私信 关注
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: