一、文件的传输

1.命令:scp

  scp  file  user@ip:/dir    ##把当前系统目录下的文件file复制到另一个系统目录下

  scp  user@ip:/file  dir

2.命令:rsync    ##数据的远程同步 ,可以加快传输速率

  • 常用参数:-r  ##同步目录里面的内容       -p  ##同步权限      -D  ##同步传输设备

-o  ##同步用户                -g  ##同步组信息

-t  ##同步时间戳              -l  ##同步链接

  • 示例:  在主机97下进行的命令rsync -r niu/ root@172.25.254.177:/mnt/的操作:
  [root@localhost mnt]# mkdir niu 

[root@localhost mnt]# touch niu/file{1..3}

[root@localhost mnt]# chmod 777 niu/*

  [root@localhost niu]# chown student.student *
  [root@localhost niu]# ls -l
  total 0
  -rwxrwxrwx. 1 student student 0 Jul 26 08:49 file1
  -rwxrwxrwx. 1 student student 0 Jul 26 08:49 file2
  -rwxrwxrwx. 1 student student 0 Jul 26 08:49 file3
  [root@localhost mnt]# rsync -r niu/ root@172.25.254.177:/mnt/
   在主机177里面进行查看: 
   [root@localhost mnt]# ls -l
   total 0
   -rwxrwxrwx 1 root root 0 Jul 26 09:00 file1
   -rwxrwxrwx 1 root root 0 Jul 26 09:00 file2
   -rwxrwxrwx 1 root root 0 Jul 26 09:00 file3
  • 在97主机下使用rsync -rp niu/ root@172.25.254.177:/mnt/的操作:

[root@localhost mnt]# rsync -rp niu/ root@172.25.254.177:/mnt/

   在177主机下进行测试 :  (文件的权限相同的)
   [root@localhost mnt]# ls -l
   total 0
   -rwxrwxrwx 1 root root 0 Jul 26 09:00 file1
   -rwxrwxrwx 1 root root 0 Jul 26 09:00 file2
   -rwxrwxrwx 1 root root 0 Jul 26 09:00 file3
  • 在97主机下使用rsync -rpogt niu/  root@172.25.254.177:/mnt/的操作:
   [root@localhost niu]# ls -l
   total 0
   -rwxrwxrwx. 1 student student 0 Jul 26 08:49 file1
   -rwxrwxrwx. 1 student student 0 Jul 26 08:49 file2
   -rwxrwxrwx. 1 student student 0 Jul 26 08:49 file3

[root@localhost mnt]# rsync -rpogt niu/ root@172.25.254.177:/mnt/
    root@172.25.254.177's password:

在177主机下测试:

[root@localhost mnt]# ls -l

    total 0
    -rwxrwxrwx 1 student student 0 Jul 26 08:49 file1
    -rwxrwxrwx 1 student student 0 Jul 26 08:49 file2
    -rwxrwxrwx 1 student student 0 Jul 26 08:49 file3
  • 进行链接的传输:

[root@localhost niu]# ln -s file1 /mnt/niu/westos

    [root@localhost niu]# ls -l
    total 0
    -rwxrwxrwx. 1 student student 0 Jul 26 08:49 file1
    -rwxrwxrwx. 1 student student 0 Jul 26 08:49 file2
    -rwxrwxrwx. 1 student student 0 Jul 26 08:49 file3
    lrwxrwxrwx. 1 root    root    5 Jul 26 09:28 westos -> file1
    [root@localhost mnt]# rsync -rl niu/ root@172.25.254.177:/mnt/
    root@172.25.254.177's password:
  • 进行设备文件的传输:
    [root@localhost mnt]# ls /dev/pts/
     0  ptmx
    [root@localhost mnt]# rsync -rD /dev/pts/ root@172.25.254.177:/mnt/
    root@172.25.254.177's password:
    在177主机下:

[root@localhost mnt]# ls

     0  ptmx

二、归档

  • 作用:可以加快不同系统之间文件的传输,使一个目录或多个文件打包为一个文件,方便传输。(归档不代表剪切)
  • 命令:tar
  • 参数:-c   ## 创建      -v   ## 显示过程      -f   ## 指定归档的文件名称

-t   ## 查看归档文件内容       -r    ## 添加文件到归档中

--get file  ## 解档指定文件    --delete  file   ##删除归档中文件

-C    dir   ## 指定解档的目录

  • 示例:etc.tar的创建和查看结果

  • 添加file文件到etc.tar归档中:
  
  
  • 归档文件的拿出(默认到当前目录下):
  
  • 解档:使档案里的文件全部拿出、解档到固定目录
  

  

三、文件的压缩

【1】zip

格式:zip -r xxx.tar.zip  xxx.tar   压缩

unzip  xxx.tar.zip    解压

示例:

 
 

打包和压缩后的文件的大小:

  [root@localhost Desktop]# ls
  etc.tar  etc.tar.zip
  [root@localhost Desktop]# du -sh *
  30M    etc.tar
  16M    etc.tar.zip

【2】gz

  • 格式:gzip  xxx.tar   压缩

gunzip  xxx.tar.gz  解压

tar zcf  xxx.tar.gz /etc/    打包+压缩

tar zxf  xxx.tar.gz  解压

  • 示例:(在压缩和解压过程中,只能产生一个 )
 
 
  • 打包和压缩后的文件的大小:
  [root@localhost Desktop]# du -sh etc.tar
  30M    etc.tar
  [root@localhost Desktop]# du -sh etc.tar.gz
  8.4M    etc.tar.gz

【3】bz2

  • 格式:bzip2  xxx.tar   压缩

bunzip2   xxx.tar.bz2  解压

tar jcf   xxx.tar.bz2  /etc/   打包+解压

       tar jxf   xxx.tar.bz2  解压
  • 示例:
  
  

【4】xz

  • 格式:xz  xxx.tar   压缩

unxz  xxx.tar.xz  解压

tar  Jcf   xxx.tar.xz   /etc/   打包+解压

       tar Jxf  xxx.tar.xz  解压
  • 示例:
  
  

注释:【2】【3】【4】解压打包可以一步完成

最新文章

  1. php编码规范
  2. localstorage sessionstorage cookie 备忘
  3. ANDROID调用webservice带soapheader验证
  4. ADO.NET ExcuteReader复习
  5. Ajax实例
  6. 纯C++ 连接SQL Server2005 数据库读写操作的小例子
  7. Python面向对象关系
  8. Linux之top
  9. 浮点数的陷阱--double i != 10 基本都是对的,不管怎么赋值
  10. WordPress怎么给分类目录排序
  11. Servlet - Upload、Download、Async、动态注册
  12. windows下gitbash中使用zip命令
  13. Ubuntu14.04+ROS 启动本地摄像头
  14. Apache JMeter5 设置中文
  15. axios 中断请求
  16. 【Code Chef】April Challenge 2019
  17. ansible学习
  18. Vue中父子组件执行的先后顺序探讨
  19. JUC线程池之 线程池拒绝策略
  20. JAVAWEB tomcat服务器启动错误原因总结

热门文章

  1. C++文件路径的写法
  2. Http:UTF-8与GB2312之间的关系
  3. Printf的缓冲机制
  4. PHP之PDO_MYSQL扩展安装步骤
  5. Django学习笔记之Cookie、Session和自定义分页
  6. 20144303 《Java程序设计》第九周学习总结
  7. SVN添加忽略目录
  8. 临时变量不能作为非const引用
  9. Pandas 高级应用 数据分析
  10. Python学习札记(十九) 高级特性5 迭代器