感谢支持
我们一直在努力

Linux基础教程学习笔记12——压缩、归档和系统间的文件传输

Linux基础教程学习笔记12——压缩、归档和系统间的文件传输

一、归档和压缩
    归档:archive

    tar命令归档的常用选项:

[root@linuxidc ~]# tar –helpExamples:
  tar -cf archive.tar foo bar  # Create archive.tar from files foo and bar.
  tar -tvf archive.tar        # List all files in archive.tar verbosely. 列出归档文件中的文件
  tar -xf archive.tar          # Extract all files from archive.tar.
 Main operation mode:
  -A, –catenate, –concatenate  append tar files to an archive 追加文件到一个归档文件
  -c, –create              create a new archive    创建一个归档文件
  -r, –append              append files to the end of an archive 将文件追加到归档文件的结尾   
  -t, –list                list the contents of an archive 列出归档文件的内容
  -u, –update              only append files newer than copy in archive 只归档比归档文件更新的文件
  -x, –extract, –get      extract files from an archive 解压归档文件
 -C, –directory=DIR        change to directory DIR 制定归档或解归档的路径
  –remove-files        remove files after adding them to the archive 归档完成之后删除原文件

 
    压缩:compress

    tar命令压缩的常用选项:
 Compression options:
                            filter through PROG (must accept -d)
  -j, –bzip2                filter the archive through bzip2
  -J, –xz                  filter the archive through xz
  -z, –gzip, –gunzip, –ungzip  filter the archive through gzip
  -Z, –compress, –uncompress  filter the archive through compress

[root@linuxidc tmp]# tar jcvf aa.bz2 aa

[root@linuxidc tmp]# tar zcvf aa.gz aa

[root@linuxidc tmp]# tar jxvf aa.bz2 /opt/

[root@linuxidc tmp]# tar zxvf aa.gz /opt/

    cpio命令归档压缩rpm安装文件

    cpio的常用选项:

[root@linuxidc tmp]# cpio –help
Examples:
  # Copy files named in name-list to the archive
  cpio -o < name-list [> archive]
  # Extract files from the archive
  cpio -i [< archive]
  # Copy files named in name-list to destination-directory
  cpio -p destination-directory < name-list
 Main operation mode:
  -i, –extract              Extract files from an archive (run in copy-in
                            mode)
  -o, –create              Create the archive (run in copy-out mode)
  -p, –pass-through        Run in copy-pass mode
  -t, –list                Print a table of contents of the input

    rpm安装包的本质是一个压缩包,安装rpm包相当于将压缩的文件解压缩到对应的文件夹:

[root@linuxidc xx]# rpm2cpio ../vsftpd-3.0.2-9.el7.x86_64.rpm |cpio -id
707 blocks
[root@linuxidc xx]# ls
etc  usr  var  xx1  xx2

二、系统间的文件传输

    scp需要依赖于openssh-client:
    scp,本地或者远端的文件互相拷贝,拷贝目录加-r选项:
[root@linuxidc ~]# scp –help
usage: scp [-12346BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file]
          [-l limit] [-o ssh_option] [-P port] [-S program]
          [[user@]host1:]file1 … [[user@]host2:]file2

[root@linuxidc ~]# scp -r /tmp root@192.168.100.1:~/xx

    rsnc:

[root@linuxidc ~]# rsync –help
Usage: rsync [OPTION]… SRC [SRC]…

 DEST
  or  rsync [OPTION]… SRC [SRC]… [USER@]HOST:DEST
  or  rsync [OPTION]… SRC [SRC]… [USER@]HOST::DEST
  or  rsync [OPTION]… SRC [SRC]… rsync://[USER@]HOST[:PORT]/DEST
  or  rsync [OPTION]… [USER@]HOST:SRC [DEST]
  or  rsync [OPTION]… [USER@]HOST::SRC [DEST]
  or  rsync [OPTION]… rsync://[USER@]HOST[:PORT]/SRC [DEST]
The ‘:’ usages connect via remote shell, while ‘::’ & ‘rsync://’ usages connect
to an rsync daemon, and require SRC or DEST to start with a module name.

 Options
 -v, –verbose              increase verbosity
 -q, –quiet                suppress non-error messages
    –no-motd              suppress daemon-mode MOTD (see manpage caveat)
 -c, –checksum              skip based on checksum, not mod-time & size
 -a, –archive              archive mode; equals -rlptgoD (no -H,-A,-X)
    –no-OPTION            turn off an implied OPTION (e.g. –no-D)
 -r, –recursive            recurse into directories
 -R, –relative              use relative path names
    –no-implied-dirs      don’t send implied dirs with –relative
 -b, –backup                make backups (see –suffix & –backup-dir)
    –backup-dir=DIR        make backups into hierarchy based in DIR
    –suffix=SUFFIX        set backup suffix (default ~ w/o –backup-dir)
 -u, –update                skip files that are newer on the receiver
    –inplace              update destination files in-place (SEE MAN PAGE)
    –append                append data onto shorter files
    –append-verify        like –append, but with old data in file checksum
 -d, –dirs                  transfer directories without recursing

    windows系统与linux系统间文件的拖拉直接传输,可以安装lrzsz.x86_64这个包
    Xshell终端可以直接输入rz命令,进行文件的传输

    linux拷贝到windows使用sz file

    Xshell直接按快捷键crtl+alt+F键调用xftp进行大文件传输;

本文永久更新链接地址:http://www.linuxidc.com/Linux/2015-03/114940.htm

赞(0) 打赏
转载请注明出处:服务器评测 » Linux基础教程学习笔记12——压缩、归档和系统间的文件传输
分享到: 更多 (0)

听说打赏我的人,都进福布斯排行榜啦!

支付宝扫一扫打赏

微信扫一扫打赏