Latest web development tutorials

Linux cpio Command

Linux command Daquan Linux command Daquan

Linux cpio command to back up files.

cpio is used to create, restore utilities to back up files, and it may be added, or unlock the file cpio tra backup files inside.

grammar

cpio [-0aABckLovV][-C <输入/输出大小>][-F <备份档>][-H <备份格式>][-O <备份档>][--block-size=<区块大小>][--force-local][--help][--quiet][--version] 或 cpio [-bBcdfikmnrsStuvV][-C <输入/输出大小>][-E <范本文件>][-F <备份档>][-H <备份格式>][-I <备份档>][-M <回传信息>][-R <拥有者><:/.><所属群组>][--block-size=<区块大小>][--force-local][--help][--no-absolute-filenames][--no-preserve-owner][--only-verify-crc][--quiet][--sparse][--version][范本样式...] 或 cpio [-0adkiLmpuvV][-R <拥有者><:/.><所属群组>][--help][--no-preserve-owner][--quiet][--sparse][--version][目的目]

Parameters:

  • -0 Or --null accept the new additional control character, usually with the find command "-print0" parameter.
  • -a or --reset-access-time Reset the access time of the file.
  • -A --append Or attached to an existing backup profile, and the backup file must be stored on the disk, and can not be placed on the drive in.
  • -b --swap or effect of this parameter and specify "-sS" the same parameters.
  • -B Input / output block size to the 5210 Bytes.
  • -c backup using the old ASCII format.
  • -C <Block size> or --io-size = <block size> set the input / output block size, the unit is Byte.
  • -d or --make-directories if necessary cpio creates its own directory.
  • -E <Template file> or --pattern-file = <template file> Specifies the template file, which contains one or more inner template styles, so cpio unlock conditions in line with the template file, the format of each column a template style.
  • -f or --nonmatching let cpio template does not meet all the conditions to unlock the file.
  • -F <Backup file> or --file = <backup file> Specifies the name of the backup file, used to replace the standard input or output, the backup files can also be accessed using another host to take this device to save the network.
  • -H File format <backup format> Specifies the backup want to use.
  • -i or --extract perform copy-in mode, restore the backup file.
  • -l <backup file> Specifies the name of the backup file, used to replace the standard input, can be read using the backup files to take to save another host device via the network.
  • -k This argument ignores not be processed, only responsible for resolving compatibility issues between different versions of cpio.
  • -l or --link manner hardwired substitution to copy files, you can use in copy-pass mode.
  • -L Or --dereference not create a symbolic link, a direct copy of the connection points to the original file.
  • -m or preserve-modification-time do not change the time to replace the file.
  • -M <Return information> or --message = <return information> Set replacement save media information.
  • When -n or --numeric-uid-gid use "-tv" parameter lists the contents of the backup file, and when coupled with the parameter "-n", will be the user ID and group ID and substitute group owner group name list the files list.
  • -o or --create perform copy-out mode, create a backup file.
  • -O <Backup file> Specifies the name of the backup file, used to replace the standard output, but also to take another host using the backup storage device to save files over the network.
  • -p or --pass-through implementation of copy-pass mode, skip the backup procedure, directly copy the file to the destination directory.
  • -r or --rename when there is need to tamper with the file name, the use of interactive mode.
  • -R <Owner> <: /> <belongs to the group> or
  • Owner belongs <belongs to the group> in copy-in mode to restore the backup file, or copy-pass mode when copying files, you can specify the backup copy of the file: ---- owner <owner> </> group.
  • -s or --swap-bytes per byte swap content.
  • -S Or --swap-halfwords exchange each nibble content.
  • -t --list Or content input presented.
  • -u or --unconditional replaced all files, regardless of the old and the new date and time or not, we are not asked directly covered.
  • -v or --verbose detail display during the execution of instructions.
  • -V Or --dot when the instruction is executed in front of each file with the execution of the program. "" No.
  • --block-size = block size <block size> Set input / output, if the value is set to 5, the block size is 2500, if set to 10, the block size is 5120, and so on.
  • --force-local force the backup files stored on the local host.
  • --help online help.
  • --no-absolute-filenames using a relative path creates file names.
  • --no-preserve-owner does not retain the owner of the file, who untied the backup files, those files on who owns.
  • -only-verify-crc When the backup file using CRC backup format, you can use this parameter to check each file within the backup file is correct.
  • --quiet do not show the number of blocks copied.
  • --sparse If a file containing a large number of consecutive 0 bytes, then save the file as a sparse file.
  • --version display version information.

Examples

Make a backup file

[[email protected] var]# ll //显示当前目录下的文件
总用量 164
drwxr-xr-x  2 root  root  4096 2008-03-30 account
drwxr-xr-x  9 root  root  4096 2008-03-30 cache
drwxr-xr-x  3 netdump netdump 4096 2008-03-30 crash
drwxr-xr-x  3 root  root  4096 2008-03-30 db
drwxr-xr-x  3 root  root  4096 2008-03-30 empty
drwxr-xr-x  3 root  root  4096 2008-03-30 ftp
drwxrwx--T  2 root  gdm   4096 4月 9 20:17 gdm
drwxr-xr-x 25 root  root  4096 2008-03-30 lib
drwxr-xr-x  2 root  root  4096 2004-08-13 local
drwxrwxr-x  6 root  lock  4096 5月 8 15:25 lock
drwxr-xr-x 14 root  root  4096 5月 8 15:14 log
lrwxrwxrwx  1 root  root   10 2008-03-30 mail -> spool/mail
drwxr-xr-x  2 root  root  4096 2004-08-13 nis
drwxr-xr-x  2 root  root  4096 2004-08-13 opt
drwxr-xr-x  2 root  root  4096 2004-08-13 preserve
drwxr-xr-x 16 root  root  4096 5月 8 15:14 run
drwxr-xr-x 16 root  root  4096 2008-03-30 spool
drwxrwxrwt  3 root  root  4096 1月 13 18:53 tmp
drwx------  2 root  root  4096 2004-07-08 tux
drwxr-xr-x  8 root  root  4096 1月 19 19:39 www
drwxr-xr-x  3 root  root  4096 2008-03-30 yp
[[email protected] var]# ls | cpio -o >123.cpio //制作备份文件
25 blocks
[[email protected] var]# ll //显示当前目录下的文件
总用量 172
-rw-r--r--  1 root  root  1024 5月 24 13:06 123.cpio
drwxr-xr-x  2 root  root  4096 2008-03-30 account
drwxr-xr-x  9 root  root  4096 2008-03-30 cache
drwxr-xr-x  3 netdump netdump 4096 2008-03-30 crash
drwxr-xr-x  3 root  root  4096 2008-03-30 db
drwxr-xr-x  3 root  root  4096 2008-03-30 empty
drwxr-xr-x  3 root  root  4096 2008-03-30 ftp
drwxrwx--T  2 root  gdm   4096 4月 9 20:17 gdm
drwxr-xr-x 25 root  root  4096 2008-03-30 lib
drwxr-xr-x  2 root  root  4096 2004-08-13 local
drwxrwxr-x  6 root  lock  4096 5月 8 15:25 lock
drwxr-xr-x 14 root  root  4096 5月 8 15:14 log
lrwxrwxrwx  1 root  root   10 2008-03-30 mail -> spool/mail
drwxr-xr-x  2 root  root  4096 2004-08-13 nis
drwxr-xr-x  2 root  root  4096 2004-08-13 opt
drwxr-xr-x  2 root  root  4096 2004-08-13 preserve
drwxr-xr-x 16 root  root  4096 5月 8 15:14 run
drwxr-xr-x 16 root  root  4096 2008-03-30 spool
drwxrwxrwt  3 root  root  4096 1月 13 18:53 tmp
drwx------  2 root  root  4096 2004-07-08 tux
drwxr-xr-x  8 root  root  4096 1月 19 19:39 www
drwxr-xr-x  3 root  root  4096 2008-03-30 yp
[[email protected] var]# 

Extracting backup file

[[email protected] var]# ls | cpio -i -l 123.cpio

Unzip the backup files, and list details

[[email protected] var]# cpio -t -I 123.cpio  
123.cpio
a.c
b.c
c.c
……省略部分结果

Mandatory decompression

[[email protected] var]# cpio -i -u -I 123.cpio 

Decompressing the reverse match, does not specify the extracted files

[[email protected] var]# cpio -i -I 123.cpio -f *.c 

//不解压.c结尾的文件

Add files to the specified file .cpio

[[email protected] var]# ls
123.cpio crash ftp local mail preserve tmp yp
account  db	gdm lock  nis  run	   tux
cache	 empty lib log  opt  spool   www
[[email protected] var]# cpio -o -O 123.cpio -A
db  //用户输入 按下Ctrl+D结束输入
1 block
[[email protected] var]# 

Backup files from the standard input

[[email protected] test]# ls              
a. a.c b.c c.c d.c	f.c
[[email protected] test]# cpio -o >123.cpio
a.c  //用户输入
b.c
c.c  //按下Ctrl+D完成输入
3 block
[[email protected] test]# 

Copying Files

[[email protected] test]# cpio -p /root
a.c  //用户输入
b.c
c.c  //按下Ctrl+D完成输入
3 block

Linux command Daquan Linux command Daquan