考试首页 | 考试用书 | 培训课程 | 模拟考场 | 考试论坛  
  当前位置:Linux认证 > 红帽认证 > 红帽认证辅导 > 文章内容
  

RHCE7认证学习笔记:压缩、归档和系统间的文件传输

来源:Linux社区 [ 2016年2月20日 ] 【

一、归档和压缩
    归档: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

首页 1 2 尾页
本文纠错】【告诉好友】【打印此文】【返回顶部
将考试网添加到收藏夹 | 每次上网自动访问考试网 | 复制本页地址,传给QQ/MSN上的好友 | 申请链接 | 意见留言 TOP
关于本站  网站声明  广告服务  联系方式  站内导航  考试论坛
Copyright © 2007-2013 中华考试网(Examw.com) All Rights Reserved