Cpio command usage

Source: Internet
Author: User
Cpio commands use cpio to obtain files or directories from the file library or copy hash files to the file library. Cpio Command Format: cpio-I [bcdmrtuv] [patterns] cpio-O [abcv] cpio-P [adlmuv] [Directory] cpio has three operation modes:
In copy-out mode, cpio copies the file to the archive package. It obtains the file name list (one row per row) from the standard input and writes the archive package to the standard output. A typical method to generate a file name list is to use the find command. You may need to use the-depth option after "find" to reduce the trouble caused by access to directories without access permissions.

In copy-in mode, cpio reads files from the archive or lists the content in the archive. It reads archive packages from standard input. Any command line parameter that is not an option is considered as the shell's globbing pattern. In an archive package, only files with matching file names can be copied. Unlike in shell'.'Matches the wildcard at the start of a pattern string.'/'You can also match the wildcard. If no mode string is provided, all files are read.

In copy-pass mode, cpio Copies files from one directory tree to another. It combines copy-in and copy-out operations, but does not use archive packages. Cpio reads the list of file names to be copied from the standard input. The target directory is provided as a non-option command line parameter.

Cpio supports the following archive formats: binary, old ASCII, new ASCII, CRC, HPUX binary, HPUX old ASCII, old tar, and posix.1 tar.

  "Binary"The format is outdated because it saves file information and cannot be transplanted between machines in different systems."Old ASCII"The format can be used across platforms, but cannot be used in file systems with more than 65536 I nodes."New ASCII"The format can be used across platforms or file systems of any size, but not all versions of cpio support. Currently, only the cpio support of GNU and system vr4 is supported."CRC"The format is similar"New ASCII"Format, and calculate the checksum for each file. Cpio calculates the checksum when creating the archive package, and verifies when unmounting the file."HPUX"The format is compatible with the cpio of hp unix. It uses a unique method to save device files.

  "Tar"The format is used to be compatible with the tar program. It cannot archive files with a file name of more than 100 characters, nor can it archive special files (Block devices or character devices )."Posix.1 tar"File with a file name that exceeds 255 characters (smaller than, unless the rightmost of the file name has"/").

By default, cpio is created to be compatible with older cpio programs"Binary"Archive packages. When you expand an archive package, cpio can automatically identify the format of the archive package and read the archive package created on machines with other bytes.
Some cpio options can only be used in the corresponding operation mode. For more information, see the overview section.
 

Options)
-0, -- null in the copy-out and copy-pass modes, the input file name ends with a null character, rather than a line break, so that even if the file name contains a line break, the archive is not affected. GNU find is one of the methods to generate a list of null end file names.
-A, -- reset-access-time: after reading the file, reset the access time of the file, which looks like it has never been accessed.
-A, -- append is appended to an existing archive package. Only used in copy-out mode. The archive package must be a disk file specified by the-O or-F (-- file) option.
-B, -- swap in the copy-in mode, the byte order of the half words and the half words in the data is reversed. -SS can use this option to convert a 32-bit integer between a large number of computers and a small number of computers.
-B sets the I/O block size to 5120 bytes. The initial block size is 512 bytes.
-- Block-size = block-size
Set the I/O block size to block-size * 512 bytes.
-C uses the old cross-platform (ASCII) archive format. -C IO-SIZE, -- IO-size = IO-SIZE sets the I/O block size to IO-SIZE bytes.
-D, -- make-directories: Create the directory where needed.
-E file, -- pattern-file = file: In copy-in mode, read the pattern string used to match the file name from the file, the content in file is treated like the Non-option parameter of cpio.
-F, -- nonmatching only Copies files that do not match any given pattern string.
-F, -- file = archive uses the archive file name instead of the standard input or output. If you use a tape drive on another machine as an archive file, use the file name"Hostname:"Start. You can add a user name and'@'As a user accessing a remote tape drive (if you have such permissions ~ /. Rhosts file ).
-- Force-local and-F,-I, or-O are used together. Even if the file name contains a colon, the archive file is considered as a local file, generally, a colon indicates a remote host name.
-H format, -- format = format uses the archive format. The valid formats are listed below, and are case sensitive."Copy-in"The default action of the mode is to automatically detect the archive format,"Copy-out"The default format is"Bin".
The old binary format of bin.
The old-fashioned (posix.1) cross-platform format of ODC.
NEWC (svr4) is a cross-platform format that supports file systems larger than 65536 I nodes.
The new CRC (svr4) cross-platform format, and the checksum is calculated.
Tar is an old-fashioned tar format.
The USTAR posix.1 tar format also recognizes GNU tar archive files, which are similar but not identical.
Cpio on hpbin hp unix uses the legacy binary format. (Store device files in a unique way)
The cross-platform format used by cpio on hpodc hp unix. (Store device files in a unique way)
-I, -- extract enters the copy-in mode.
-I archive uses the archive file name instead of the standard input. If you create an archive file for a tape drive on another machine, use the file name"Hostname:"Start. You can add a user name and'@'As a user accessing a remote tape drive (if you have such permissions ~ /. Rhosts file ).
-K is invalid. It is only used to be compatible with cpio of other versions.
-L, -- link, if possible, connects to the file instead of copying.
-L, -- dereference disconnects the symbolic connection (copy the file to which the symbolic connection points, rather than the connection itself ).
-M, -- preserve-modification-time when a file is created, the previous file modification time is retained.
-M message, -- message = message when the backup media (such as tape or floppy disk) reaches the end of the volume, a message is displayed to remind you to insert the next volume. If the message contains a string"% D"It is replaced with the current volume number (starting from 1 ).
-N, -- Numeric-UID-gid: When verbose is used to display the content, UID and GID are displayed in numbers instead of translated into names.
-- No-absolute-filenames in copy-in mode, even if they have absolute path names in the archive package. Create all related files in the current directory,
-- No-preserve-owner in copy-in and copy-pass modes, the file owner relationship is not changed (note: the suspect is not retained), so that they belong to users who expand them. This is the default behavior of common users. Therefore, System V users do not accidentally disclose files (give away ).
-O, -- create enters the copy-out mode.
-O archive uses the archive file name instead of the standard output. If you create an archive file for a tape drive on another machine, use the file name"Hostname:"Start. You can add a user name and'@'As a user accessing a remote tape drive (if you have such permissions ~ /. Rhosts file ).
-- Only-verify-CRC: When a CRC archive package is read in copy-in mode, the CRC code of the test file is not expanded.
-P, -- pass-through enters the copy-pass mode.
-- Quiet does not display the number of copies.
-R, -- rename the interactive file.
-R [user] [:.] [Group], -- owner [user] [:.] [Group] In copy-out and copy-pass modes, set the owner of all files to the specified user and/or user group. Both the user and user group must exist. If the user group is omitted, but the separator is provided":"Or".'To use the user group for logon. Only a super user can change the owner of a file.
-- In copy-out and copy-pass modes, sparse writes a file with a large block of data 0 into a sparse file ).
-S, -- Swap-bytes in copy-in mode, swap every byte in the file.
-S, -- Swap-halfwords in the copy-in mode, the half word in each word (4 bytes) in the file is exchanged.
-T, -- List displays the content of the input archive package.
-U, -- unconditional replaces all files, and no longer asks whether to replace existing files with old files.
-V, -- verbose: list the processed files, and the-T option can be used to list one'Ls-l'Style list. If the user and user group name of the archive file does not exist in the local system, they will be replaced with their digital UID and GID corresponding to the user and user group names of the local system.
-V -- dot: each time a file is processed,".".
-- Version: displays the version number of the cpio program and exits. Cpio is often used with shell. -O common standard input devices read the name of the file to be copied and output the copied archive file through the standard output device. Generally, the input/output redirection or pipeline principle is used to achieve the real replication function. (1) Using cpio backup: [Example 1] $ find temo-print | cpio-ocdv>/dev/rfd0135ds18 example: Find. | cpio-Co> .. /initrd: Back Up Files in the temp directory to a floppy disk. -O indicates the output mode.-C generates a file with header information. -D indicates that the directory is generated as needed, and-V indicates that information is continuously displayed during command execution. Use ">" to direct the result to a floppy disk. [Example 2] $ ls | cpio-o>/usr/backup: Copy all files in the current directory to backup archive file [Example 3] $ ls *. c | cpio-o> backup copies all C Programs in the working directory. [Example 4] $ ls | cpio-P/usr/linfs/tempdir copy the files in the current working directory to the/usr/linfs/tempdir directory without generating archive file (2) cpio recovery: [Example 5] $ cpio-icdv </dev/rfd0135ds18 example: cpio-I <.. /initrd release the initrd file in the upper directory to the current folder and restore the files in the floppy disk. -I tells cpio to use the file as its input.-D generates a directory as needed.-V displays all information during execution.-C has the header file format. [Example 6] $ cpio-icdv "* stat. WP "</dev/rfd0135ds18 only restores * stat. WP files [Example 7] $ cpio-I only restore *. f file sequence: (gzip compressed file) the decompressed file corresponding to the gzip compressed file is gunzip. The name of the compressed file is 2.16.gz ". Command Format: gzip filename gunzip filename cpio command usage

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.