一、文件的传输

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】解压打包可以一步完成

Linux文件在系统中传输的更多相关文章

  1. linux、windows系统间传输文件

    日常工作中经常涉及到系统间的文件传输,下面就简单说一下常用的方法   linux--windows      工具:winscp.SecureCRT.Zmodem(sz, rz)   linux--l ...

  2. Linux文件虚拟机系统只读Read-only file system的快速解决方法

    问题描述:上周公司的私有云(底层架构是Openstack+KVM,目前稳定性还不够好,开发团队在改进中)一个计算节点挂掉,之后恢复后发现这个计算节点的所有Linux系统都变成只读了,复制文件提示:Re ...

  3. android 怎样内置/预置/预编译文件(运行程序,应用程序,apk, jar, lib 等随意文件)到系统中

    方法一:  如果要内置的软件名称为iperf.exe 1. 将iperf.exe放到Codebase的随意一个文件夹下(该文件夹必须可以在搜索Android.mk时被搜索到),比方system/ipe ...

  4. 在Linux和Windows系统中输出目录结构

    前言 一直以来就想在写文章时,能以文本形式(而不是截图)附上项目的目录结构,今天终于知道怎么操作了,在这分享一下. Linux 首先说下Linux上输出目录结构的方法. yum安装tree 需要支持t ...

  5. 加载XML文件到系统中

    using System;using System.Data;using System.IO;using System.Xml;using System.Collections.Generic; na ...

  6. Linux Shell: 统计系统中占用Swap 的程序PID和占用大小

    #!/bin/bash  SUM=0 OVERALL=0 for DIR in `find /proc/ -maxdepth 1 -type d -regex "^/proc/[0-9]+& ...

  7. Xshell6远程访问linux及Xftp6远程针对linux系统中文件操作(附图文详解)

    1.首先我们需要先做好前期准备工作,需要到XManager6官网上将Xshell及Xftp下载并安装,安装过程一直下一步就好了.这里是其官网:http://www.xshellcn.com/.安装完成 ...

  8. Linux系统中cgroup功能介绍

    1  Cgroups简介 1.1 What are cgroups ? Cgroups(控制组)是Linux内核的一个功能,用来限制.统计和分离一个进程组的资源(CPU.内存.磁盘输入输出等).换句话 ...

  9. Linux文件传输协议2019-7-9

    FTP(file transfer Protocol)是一种在互联网中进行文件传输的协议,基于客户端/服务器模式,默认使用20.21号端口,其中端口20(数据端口)用于数据传输,端口21(命令端口)用 ...

随机推荐

  1. java反射 - getXXX 与 getDeclaredXXX

    1.getXXX 和 getDeclaredXXX java 里 Class<?> 有下面这些方法: 类似的方法有: 2.getMethod(s) 和 getDeclaredMethod( ...

  2. Nginx访问控制_IP访问控制(http_access_module)原理、局限性、解决方法讲解

    基于IP的访问控制,基于Nginx的http_access_module模块,是Nginx本身内置的模块,不需要安装的时候配置.也就是允许哪些IP访问,不允许哪些IP访问 server { liste ...

  3. go channel 阻塞

    初接触 go 有不对得请解释下 Channel是goroutine之间进行通信的一种方式,先看下面代码为什么会阻塞: func closer(ch chan int) { ch <- 1 log ...

  4. JAVA小工具打包

    D: cd D:\xxx\IPOSpider javac -d bin/ src/com/xxx/IPOSpider.java src/com/xxx/ConfigProperties.java -c ...

  5. easyui combobox 拼音检索快捷选择输入

    easyui combobox 拼音检索快捷选择输入 效果如图   $.ajax({ url: UserActionUrl + '?action=listuserworktype', dataType ...

  6. 【线性判别】Fisher线性判别(转)

    今天读paper遇到了Fisher线性判别的变体, 所以来学习一下, 所以到时候一定要把PRMl刷一遍呀 以下两篇论文一起阅读比较好: 论文1: https://blog.csdn.net/Rainb ...

  7. 2017 ACM-ICPC 亚洲区(乌鲁木齐赛区)网络赛-A banana·

    2017-09-09 16:41:28 writer:pprp 题意很好理解就不说了,实现比较清晰,选择邻接表来做 但是我用的是链表来实现的,所以导致出现了很多问题,最后卡的最长时间的一个问题是 应该 ...

  8. UVa 10883 超级平均数(二项式系数+对数计算)

    https://vjudge.net/problem/UVA-10883 题意: 给出n个数,每相邻两个数求平均数,依次类推,最后得到1个数,求该数. 思路: 演算一下可以发现最后各个数的系数就是二项 ...

  9. 一些putty的应用设置

    把windows下putty的key转换成linux上使用的rsa key    http://ask.apelearn.com/question/937 putty生成的密钥导入connectbot ...

  10. 关于Gulp

    Gulp & webpack 配置详解http://www.jianshu.com/p/2d9ed1fe3e8c 使用 Gulphttp://hwaphon.site/?p=439 前端构建工 ...