`
OuYangGod
  • 浏览: 53058 次
  • 性别: Icon_minigender_1
  • 来自: 南京
社区版块
存档分类
最新评论

cpio命令

阅读更多
cpio: Creates an archive or restores files from an archive

Format
cpoi --create [options]
cpoi --extract [options] [patterns]
copi --pass-through [options] directory


Description
     The cpio utility has three modes of operation: Create mode places multiple files into a single archive file, extract mode restores files from an archive, and pass-through mode copies a directory hierarchy to another location. The archive file used by cpio may be saved on disk, tape, other removable media, or a remote system.

     Create mode reads a list of ordinary or directory filenames from standard input and writes the resulting archive file to standard output. You can use this mode to create an archive. Extract mode reads the name of an archive from standard input and extracts files from that archive. You can decide to restore all the files from the archive or only those whose names match specific patterns. Pass-through mode reads ordinary or directory filenames from standard input and copies the files to another location on the disk.

Arguments
     By default cpio in extract mode extracts all files found in the archive. You can choose to extract files selectively by supplying one or more patterns. If the name of a file in the archive matches one of the patterns, that file is extracted; otherwise, it is ignored. The cpio patterns are similar to shell wildcards except that patterns match slashes (/ ) and a leading period (.) in a filename.

     In pass-through mode you must give the name of the target directory as an argument to cpio.

Options
Major Options
     Three options determine the mode in which cpio operates. You must include exactly one of these options whenever you use cpio.

     --extract -i
     Reads the archive from standard input and extracts files. Without any patterns on the command line, cpio extracts all the files from the archive. With patterns specified, cpio extracts only files with names the patterns match. The following example extracts from the SCSI tape at /dev/st0 only those files whose names end in .c :
     $ cpio -i \*.c < /dev/st0
     The backslash prevents the shell from expanding the * before it passes the argument to cpio.

     --create -o
     Constructs an archive from the files named on standard input. These files may be ordinary or directory files, and each must appear on a separate line. The archive is written to standard output as it is built. The find utility frequently generates the filenames that cpio uses. The following command builds an archive of the entire local system and writes it to the SCSI tape at /dev/st0:
     $ find / -depth -print | cpio -o > /dev/st0
     The -depth option causes find to search for files in a depth-first search, reducing the likelihood of permissions problems when you restore the files from the archive.

     --pass-through -p
     Copies files from one place on the system to another. Instead of constructing an archive file containing the files named on standard input, cpio copies them into the directory (the last argument given to cpio). The effect is the same as if you had created an archive with copy-out mode and then extracted the files with copy-in mode, but using pass-through mode avoids creating an archive. The following example copies the files in the working directory and all subdirectories into /home/alex/code:
     $ find . -depth -print | cpio -pdm ~alex/code

Other Options
     The remaining options alter the behavior of cpio. These options work with one or more of the preceding major options.

     --reset-access-time -a
     Resets the access times of source files after copying them so that they have the same access time after copying as they did before.

     -B
     Sets the block size to 5,120 bytes instead of the default 512 bytes.

     --block-size=n
     Sets the block size used for input and output to n * 512-byte blocks.

     --make-directories -d
     Create leading directories where needed.

     --file=archive -F
     Uses archive as the name of the archive file. In extract mode, reads from archive instead of standard input. In create mode, writes to archive instead of standard output. You can use this option to access a device on another system on a network.

     --preserve-modification-time -m
     Preserves the modification times of files that are extracted from an archive. Without this option the files show the time they were extracted. With this option the created files show the time they had when they were copied into the archive.

     --list -t
     Displays a table of contents of the archive. This option works only with the --extract option, although no files are actually extracted from the archive. With the --verbose option, it displays a detailed table of contents in a format similar to that used by ls -l.

     --verbose -v
     Lists files as they are processed. With the ––list option, it displays a detailed table of contents in a format similar to that used by ls -l.

Examples:
     The first example creates an archive of the files in Jenny's home directory, writing the archive to a tape drive supported by the ftape driver:
     $ find /home/jenny -depth -print | cpio -oB > /dev/ftape

     To check the contents of the archive file and display a detailed listing of the files it contains, use
     $ cpio -itv < /dev/ftape

     The following command restores the files that formerly were in the memo subdirectory of Jenny's home directory:
     $ cpio -idm /home/jenny/memo/\* < /dev/ftape
分享到:
评论

相关推荐

    linux下的dd和cpio命令.pdf

    linux下的dd和cpio命令.pdf

    Linux cpio命令用法详解

    Linux cpio命令 Linux cpio命令用于备份文件。 cpio是用来建立,还原备份档的工具程序,它可以加入,解开cpio或tra备份档内的文件。 语法 cpio [-0aABckLovV][-C ][-F ][-H ][-O ][--block-size=][--force-local][-...

    cpio命令使用

    cpio命令的使用 利用cpio 可将文件或目录从文件库获取出来或将数据拷贝到文件库。 cpio 的指令格式: cpio –i[bcdmrtuv] [patterns] cpio –o [abcv] cpio –p [adlmuv][directory] 说明:cpio 共有三种基本...

    cpio命令详解

    cpio 命令大全。看了就知道好用 关于cpio生成。Linux自带了两个重要的工具:gen_initramfs_list.sh和gen_init_cpio

    cpio命令 复制文件到归档包

    cpio命令主要是用来建立或者还原备份档的工具程序,cpio命令可以复制文件到归档包中,或者从归档包中复制文件。 语法格式: cpio [参数] 常用参数: -0 接受新增列控制字符,通常配合find指令的“-print0”参数...

    linux命令cpio用法详解

    详细讲解了cpio命令的用法,包括很多的例子

    cpio2.9命令源代码,讲述了文件如何压缩

    cpio - 存取归档包中的文件 语法 Syntax cpio -o [ -aBLuvV ] [ -C bufsize ] [ -c | -H format ][ -K volumesize ] [ [ -O file [, file ... ] ] [ -M message ] ] [ -Pifd,ofd ] cpio -i [ -6...

    CentOS下tar打包解压详解(解压到指定文件夹)

    本文介绍了tar命令、gzip, zcat 命令、bzip2, bzcat 命令、compress 命令、dd 命令、cpio 命令,具体如下: tar命令 解压文件到指定目录: tar -zxvf /home/zjx/aa.tar.gz -C /home/zjx/pf tar [-cxtzjvfpPN] ...

    第一篇 基础篇UNIX操作系统

    二、cpio命令 21 4.6 文件压缩和解压程序 22 一、compress 压缩命令 22 二、pack 压缩文件 22 三、gzip 压缩文件 23 四、pkzip压缩文件 23 第五章 UNIX简单维护与管理 23 5.1 UNIX开机举例 23 5.2 UNIX关机举例 23 ...

    redhat linux教材20课程学习文档

    11.4.4 cpio 命令 11.4.5 dump 命令 11.5 第三方备份软件 11.6 磁带机的介绍及使用 第十二章 软件包管理 12.1 rpm 基础 12.2 rpm 主要运行方式和常用选项 12.3 查找 rpm 信息 12.4 rpm 包的安装与删除 12.5 rpm ...

    LINUX 24学时教程

    5.3.2 建立cpio档案文件 78 5.3.3 使用gzip命令压缩文件 78 5.3.4 使用compress命令压缩文件 79 5.4 课时小结 79 5.5 专家答疑 80 5.6 练习题 80 第6学时 使用shell 81 6.1 什么是shell 81 6.2 系统中都有哪几种...

    入门级的SUN培训资料

    4.cpio命令 24 5.compress,uncompress,zcat 命令 25 6.mt 命令 25 7.dd 命令 25 8.异地使用磁带机(必须为可信任用户,参见11.3) 25 十.改变运行等级 25 (一)系统引导 25 (二)系统操作等级 26 1. 运行等级...

    AIX系统管理

    16.2.6.2 cpio命令 163 16.2.6.3 dd命令 163 16.2.7 其他与备份相关命令 163 16.2.8 备份文档的策略 164 第 17 章 网络管理 165 17.1 TCP/IP基本概念 165 17.2 互联网实例 165 17.3 TCP/IP配置 167 17.4 配置IP地址...

    solaris操作系统基础知识

    7.4.2 cpio命令.............. 58 7.5 文件压缩和解压程序 ..... 60 7.5.1 compress 压缩命令.............................. 60 7.5.2 pack 压缩文件 .... 60 7.5.3 gzip 压缩文件...

    telinit命令 更改系统的运行级别

    使用telinit命令可以更改Linux系统的运行级别。运行级别可以是0~6之间的一个数字,...与该功能相关的Linux命令:mmove命令 – 移动文件或目录rpm2cpio命令 – 文件格式转换chmod命令 – 改变文件或目录权限chroot命令

    rhmask命令 加密和解密文件

    Linux rhmask命令用于对文件进行加密和解密操作。执行rhmask指令可制作加密过的文件,方便用户在公开的...与该功能相关的Linux命令:udevadm info命令 – 查询udev数据库中的设备信息rpm2cpio命令 – 文件格式转换gzexe

    linux解压命令大全

    Linux中解压和安装方法2008/07/15 03:02 P.M.LINUX压缩包(cpio/gz/zip/bin/tar) cpio : cpio -idmv &lt; file_name.cpio.............

Global site tag (gtag.js) - Google Analytics