Cpio command details

Source: Internet
Author: User

From: http:// OS .51cto.com/art/200512/14302.htm

A useful command. I have not found any posts posted by my friends. So I sent it. Hope to be useful.
I hope you can share some useful and difficult-to-find commands.
Cpio command usage
Cpio-access files in an archive
Syntax
Cpio
-O [-abluvv] [-C bufsize] [-c |-H format] [-K volumesize] [[
-O file [, file...] [-m message] [-pifd, ofd]
Cpio-I [-6 abbcdfkmnqrssttuvv] [-C bufsize] [[-I file [, file...]
[-M message] [-pifd, ofd] [pattern...]
Cpio-P [-adllmruvv] [-pifd, ofd] Directory
Description)
Cpio can store and read files from archive packages in cpio or tar format. An archive package is a file that contains other files and related information. Related information includes: file name, owner, timestamp, and access permission. The archive package can be another file on the disk, or a tape or pipeline.
Cpio has three operation modes:
In
In copy-out mode, cpio copies the file to the archive package. It obtains the file name list (one row in one row) from the standard input ),
Write 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 the find command,
Reduce the trouble caused by accessing directories without access permissions.
In copy-in mode, cpio reads files from the archive,
Or list the content in the archive. It reads archive packages from standard input. Any command line parameter that is not an option is considered as a shell wildcard pattern );
In the archive package, only files with matching pattern strings can be copied. Unlike in shell, '.' at the start of a file name can match the wildcard at the start of a pattern string,
The '/' in the file name can also match the wildcard character. 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. The "Old ASCII" format can be used across platforms, but cannot exceed
In the file system of the 65536 I nodes. The "New ASCII" format can be used across platforms, and is applicable to file systems of any size, but not all versions of cpio
Currently, only cpio of GNU and system vr4 is supported. The "CRC" format is similar to the "New ASCII" format,
Calculate the checksum for each file. Cpio calculates the checksum when creating the archive package, and verifies when unmounting the file. The "HPUX" format is used to be compatible with cpio of hp unix,
It uses a unique method to save device files.
The "tar" 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" format cannot archive files with more than 255 characters (smaller than, unless there is a "/" on the rightmost side of the file name "/").
By default, cpio creates an archive package in "binary" format to be compatible with older cpio programs. 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. Before the host name, you can add a user name and '@' as the user accessing the 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 format is listed below, which can be case sensitive. The default action of the "copy-in" mode is to automatically detect the archive format, and the default format of "copy-out" 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 an archive file name instead of a standard input. If you create an archive file for a tape drive on another machine, use "hostname:" As the file name :"
Start. Before the host name, you can add a user name and '@' as the user accessing the remote tape drive (if you have such permissions, generally in the user's ~ /. 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 the 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 );
Make them belong to the 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 "hostname:" As the file name :"
Start. Before the host name, you can add a user name and '@' as the user accessing the remote tape drive (if you have such permissions, generally in the user's ~ /. 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
Mode, 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 ":" or
". ', The user group used to log on to the specified user. 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 is used to list the processed files, and the-T option can be used to list a list of 'LS-l' styles. Verbose)
If the local system does not have the user and user group names of the archive files, 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, a "." is displayed ".".
-- Version: displays the version number of the cpio program and exits.

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.