Usage: cpio [OPTION...] [destination-directory]
GNU `cpio' copies files to and from archives
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
Operation modifiers valid in any mode:
--block-size=BLOCK-SIZE Set the I/O block size to BLOCK-SIZE * 512
bytes
-B Set the I/O block size to 5120 bytes
-c Identical to "-H newc", use the new (SVR4)
portable format.If you wish the old portable
(ASCII) archive format, use "-H odc" instead.
-C, --io-size=NUMBER Set the I/O block size to the given NUMBER of
bytes
--force-local Archive file is local, even if its name contains
colons
-f, --nonmatching Only copy files that do not match any of the given
patterns
-F, --file=[[USER@]HOST:]FILE-NAME
Use this FILE-NAME instead of standard input or
output. Optional USER and HOST specify the user
and host names in case of a remote archive
-H, --format=FORMAT Use given archive FORMAT
-M, --message=STRING Print STRING when the end of a volume of the
backup media is reached
-n, --numeric-uid-gid In the verbose table of contents listing, show
numeric UID and GID
--quiet Do not print the number of blocks copied
--rsh-command=COMMAND Use remote COMMAND instead of rsh
-v, --verbose Verbosely list the files processed
-V, --dot Print a "." for each file processed
-W, --warning=FLAG Control warning display. Currently FLAG is one of
'none', 'truncate', 'all'. Multiple options
accumulate.
Operation modifiers valid only in copy-in mode:
-b, --swap Swap both halfwords of words and bytes of
halfwords in the data. Equivalent to -sS
-r, --rename Interactively rename files
-s, --swap-bytes Swap the bytes of each halfword in the files
-S, --swap-halfwords Swap the halfwords of each word (4 bytes) in the
files
--to-stdout Extract files to standard output
-E, --pattern-file=FILE Read additional patterns specifying filenames to
extract or list from FILE
--only-verify-crc When reading a CRC format archive, only verify the
CRC's of each file in the archive, don't actually
extract the files
Operation modifiers valid only in copy-out mode:
-A, --append Append to an existing archive.
-O [[USER@]HOST:]FILE-NAME Archive filename to use instead of standard
output. Optional USER and HOST specify the user
and host names in case of a remote archive
Operation modifiers valid only in copy-pass mode:
-l, --link Link files instead of copying them, when
possible
Operation modifiers valid in copy-in and copy-out modes:
--absolute-filenames Do not strip file system prefix components from
the file names
--no-absolute-filenames Create all files relative to the current
directory
Operation modifiers valid in copy-out and copy-pass modes:
-0, --null A list of filenames is terminated by a null
character instead of a newline
-a, --reset-access-time Reset the access times of files after reading
them
-I [[USER@]HOST:]FILE-NAME Archive filename to use instead of standard input.
Optional USER and HOST specify the user and host
names in case of a remote archive
-L, --dereference Dereference symbolic links (copy the files
that they point to instead of copying the links).
-R, --owner=[USER][:.][GROUP] Set the ownership of all files created to the
specified USER and/or GROUP
Operation modifiers valid in copy-in and copy-pass modes:
-d, --make-directories Create leading directories where needed
-m, --preserve-modification-time
Retain previous file modification times when
creating files
--no-preserve-owner Do not change the ownership of the files
--sparse Write files with large blocks of zeros as sparse
files
-u, --unconditional Replace all files unconditionally
Informative options:
-?, --help Give this help list
--license Print license and exit
--usage Give a short usage message
--version Print program version
Mandatory or optional arguments to long options are also mandatory or optional
for any corresponding short options.
Report bugs to
Usage: cpio [OPTION...] [destination-directory]
GNU `cpio' copies files to and from archives
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
Operation modifiers valid in any mode:
--block-size=BLOCK-SIZE Set the I/O block size to BLOCK-SIZE * 512
bytes
-B Set the I/O block size to 5120 bytes
-c Identical to "-H newc", use the new (SVR4)
portable format.If you wish the old portable
(ASCII) archive format, use "-H odc" instead.
-C, --io-size=NUMBER Set the I/O block size to the given NUMBER of
bytes
--force-local Archive file is local, even if its name contains
colons
-f, --nonmatching Only copy files that do not match any of the given
patterns
-F, --file=[[USER@]HOST:]FILE-NAME
Use this FILE-NAME instead of standard input or
output. Optional USER and HOST specify the user
and host names in case of a remote archive
-H, --format=FORMAT Use given archive FORMAT
-M, --message=STRING Print STRING when the end of a volume of the
backup media is reached
-n, --numeric-uid-gid In the verbose table of contents listing, show
numeric UID and GID
--quiet Do not print the number of blocks copied
--rsh-command=COMMAND Use remote COMMAND instead of rsh
-v, --verbose Verbosely list the files processed
-V, --dot Print a "." for each file processed
-W, --warning=FLAG Control warning display. Currently FLAG is one of
'none', 'truncate', 'all'. Multiple options
accumulate.
Operation modifiers valid only in copy-in mode:
-b, --swap Swap both halfwords of words and bytes of
halfwords in the data. Equivalent to -sS
-r, --rename Interactively rename files
-s, --swap-bytes Swap the bytes of each halfword in the files
-S, --swap-halfwords Swap the halfwords of each word (4 bytes) in the
files
--to-stdout Extract files to standard output
-E, --pattern-file=FILE Read additional patterns specifying filenames to
extract or list from FILE
--only-verify-crc When reading a CRC format archive, only verify the
CRC's of each file in the archive, don't actually
extract the files
Operation modifiers valid only in copy-out mode:
-A, --append Append to an existing archive.
-O [[USER@]HOST:]FILE-NAME Archive filename to use instead of standard
output. Optional USER and HOST specify the user
and host names in case of a remote archive
Operation modifiers valid only in copy-pass mode:
-l, --link Link files instead of copying them, when
possible
Operation modifiers valid in copy-in and copy-out modes:
--absolute-filenames Do not strip file system prefix components from
the file names
--no-absolute-filenames Create all files relative to the current
directory
Operation modifiers valid in copy-out and copy-pass modes:
-0, --null A list of filenames is terminated by a null
character instead of a newline
-a, --reset-access-time Reset the access times of files after reading
them
-I [[USER@]HOST:]FILE-NAME Archive filename to use instead of standard input.
Optional USER and HOST specify the user and host
names in case of a remote archive
-L, --dereference Dereference symbolic links (copy the files
that they point to instead of copying the links).
-R, --owner=[USER][:.][GROUP] Set the ownership of all files created to the
specified USER and/or GROUP
Operation modifiers valid in copy-in and copy-pass modes:
-d, --make-directories Create leading directories where needed
-m, --preserve-modification-time
Retain previous file modification times when
creating files
--no-preserve-owner Do not change the ownership of the files
--sparse Write files with large blocks of zeros as sparse
files
-u, --unconditional Replace all files unconditionally
Informative options:
-?, --help Give this help list
--license Print license and exit
--usage Give a short usage message
--version Print program version
Mandatory or optional arguments to long options are also mandatory or optional
for any corresponding short options.
Report bugs to
CPIO(1L) CPIO(1L) 名称 cpio - アーカイブファイルへのファイルのコピーや、アーカイブファイルから ファイルへのコピーをおこなう 書式 cpio {-o|--create} [-0acvABLV] [-C bytes] [-H format] [-M message] [-O [[user@]host:]archive] [-F [[user@]host:]archive] [--file=[[user@]host:]archive] [--format=format] [--message=message] [--null] [--reset-access-time] [--verbose] [--dot] [--append] [--block- size=blocks] [--dereference] [--io-size=bytes] [--help] [--version] < name-list [> archive] cpio {-i|--extract} [-bcdfmnrtsuvBSV] [-C bytes] [-E file] [-H format] [-M message] [-R [user][:.][group]] [-I [[user@]host:]archive] [-F [[user@]host:]archive] [--file=[[user@]host:]archive] [--make-directo- ries] [--nonmatching] [--preserve-modification-time] [--numeric-uid- gid] [--rename] [--list] [--swap-bytes] [--swap] [--dot] [--uncondi- tional] [--verbose] [--block-size=blocks] [--swap-halfwords] [--io- size=bytes] [--pattern-file=file] [--format=format] [--owner=[user][:.][group]] [--no-preserve-owner] [--message=message] [--help] [--version] [pattern...] [< archive] cpio {-p|--pass-through} [-0adlmuvLV] [-R [user][:.][group]] [--null] [--reset-access-time] [--make-directories] [--link] [--preserve-modifi- cation-time] [--unconditional] [--verbose] [--dot] [--dereference] [--owner=[user][:.][group]] [--no-preserve-owner] [--help] [--version] destination-directory < name-list 解説 本マニュアルは、GNU 版の cpio について説明します。 cpio は、cpio 形式も しくは tar 形式のアーカイブファイルに格納されたファイルを取り出したり、 そ の逆を行ったりします。アーカイブファイルの中には、ファイルそのものの 情報の他に、それら個々のファイルについての所有者や属性その他の情報を 格 納 してあります。アーカイブファイルは、ディスク上のファイルでも、テープ 上に格納してあっても、もしくはパイプであっても構いません。 cpio は、3つ の操作モードを持っています。 コ ピーアウトモードでは、 cpio はファイルをアーカイブファイルにコピーし ます。cpio は、標準入力からファイル名のリストを1行ずつ読み込み、標準 出 力 にそのファイルのアーカイブを書き出します。ファイルリストの作成には、 find コマンドが多く使われます。 find コマンドに、-depth オプションを 付 加 してやって、ディレクトリの属性によって読み込み不可であったり、検索が 出来なかったりする問題を最小限に抑えるようにして下さい。 コピーインモードでは、 cpio はファイルをアーカイブファイル、もしくは ア ー カイブの内容のリストからコピーします。cpioは、アーカイブを標準入力か ら読み込みます。オプションでないコマンドラインの引数は、すべてシェル に よ って展開される文字列として解釈されます。これは、アーカイブ内のファイ ル名が、この文字列によって指定されるパターンにマッチする場合にのみそ の フ ァイルを展開することを意味します。また、シェルでの解釈にかかわらず、 ファイル名の先頭に‘.’を含む場合には、パターンの最初にワイルドカードがあ る場合にパターン一致します。そして、ファイル名に‘/’を含む場合にも、ワイ ルドカードによる一致が期待できます。パターンが指定されない場合には、 全 てのファイルが展開対象となります。 コ ピーパスモードでは、 cpio はファイルをあるディレクトリから別のディレ クトリにコピーします。実際には、アーカイブファイルを用いて、コピーア ウ ト モ ー ドとコピーインモードを組み合わせて実行するような形になります。 cpioは、コピーするファイルリストを標準入力から受けとります。これらの フ ァ イルのコピー先のディレクトリについては、オプション以外の引数で与えら れます。 cpio は、 binary, old ASCII, new ASCII, crc, HPUX binary, HPUX old ASCII, old tar, POSIX.1 tar の各形式のアーカイブフォーマットをサポート します。 binaryフォーマットは、異なるマシンアーキテクチャの間でアーカイ ブ フォーマットが異なるため、ほとんど使われません。 old ASCIIフォーマッ トは、異なるマシンアーキテクチャの間でのアーカイブの互換性は保たれま す が、65536 個を超えるi-nodesを備えるシステムで使われることを想定してませ ん。 new ASCIIフォーマットは、異なるマシンアーキテクチャの間でのアー カ イブの互換性は保たれます。old ASCIIフォーマットのように、ファイルシステ ムのサイズの制限はありませんが、全てのバージョンの cpio でこの形式を サ ポ ートするわけではありません。現状でこのフォーマットをサポートするcpio は、GNU cpio と、SVR4のcpioのみです。 crcフォーマットは、new ASCIIフ ォ ー マットと似てますが、アーカイブ作成時に cpio が各ファイルについてチェ ックサムを計算し、アーカイブ内に含めるところが異なります。このチェッ ク サ ムは、アーカイブからファイルを取り出す時のベリファイに使用されます。 HPUXフォーマットは、デバイスファイルを格納する形式が他のcpioと 異 な る HPUXのcpio形式との互換性を持たせるために存在します。 tarフォーマットは、 tar との互換性を持たせるために存在します。tarフォー マットでは、アーカイブされるファイル名としては、100文字を超えるものは使 え ません。そして、ブロックデバイス特殊ファイルやキャラクタデバイス特殊 ファイルをアーカイブすることも出来ません。 POSIX.1 tarフォーマットは 、 ア ーカイブされるファイル名としては、255文字を超えるものは使えません。( ちょうどその場所に、"/"が含まれる場合は除きます)。 デフォルトでは、 cpio は古い cpio との互換性のためにバイナリフォーマ ッ ト アーカイブを作成します。アーカイブを展開する場合には、 cpio は自動的 に読み込まれたアーカイブの種類、そして異なるバイトオーダのマシンで作 成 されたかどうかを判断します。 あ る cpio のオプションは、操作モードを指定します。どのオプションがどの モードに対応するかについては、形式のセクションを見て下さい。 オプション -0, --null コピーアウトおよびコピーパスモードにおいて、改行のかわりにヌル文 字で終了するファイル名のリストを、読み込みます。これは、改行を含 むファイル名を持つファイルをアーカイブできるようにするためです。 GNU find を使うことで、ヌル文字で終了するファイル名のリストを生 成することが出来ます。 -a, --reset-access-time ファイルを読み込んだ後に、それらのファイルのアクセスタイムの再設 定を行います。これは、これらのファイルがその時点で読み込まれたも ののように見えないようにするためです -A, --append すでに存在するアーカイブファイルに追加書き込みをします。本オプシ ョ ンを使うためには、は、 -O もしくは -F (--file) オプションにて 指定した名前のアーカイブファイルがディスク上に存在する必要があり ます。 -b, --swap コ ピーインモードにおいて、データ中の1ワード(32ビット)データの上 下16ビットを入れ換え、1ハーフワード(16ビット)の上下8ビットを入れ 換 えます。本オプションは、 -sS と同等です。本オプションは、ビッ グエンディアンマシンとリトルエンディアンのマシンの間で 32ビッ ト 整数を変換するために用います。 -B I/O ブロックサイズを5120バイトに設定します。ブロックサイズの初期 値は512バイトです。 --block-size=BLOCK-SIZE I/OブロックサイズをBLOCK-SIZE * 512バイトに設定します。 -c アーカイブ形式として、old ASCIIフォーマットを用います。 -C IO-SIZE, --io-size=IO-SIZE I/OブロックサイズをIO-SIZEで指定しただけのバイト数に設定します。 -d, --make-directories 必要に応じてディレクトリを作成します。 -E FILE, --pattern-file=FILE コピーインモードにおいて、ファイル名を特定するためのパターン指定 、もしくはファイルリストをファイル名 FILE から読み出します。ファ イル名FILEで特定できるファイルに記述された各行は、 cpio のオプシ ョン以外の文字列で指定されたものとして扱われます。 -f, --nonmatching 与えられたパターンのいずれにも一致しないファイルのみ扱います。 -F, --file=archive 標準入力もしくは標準出力のかわりに、指定されたアーカイブファイル を用います。他のマシンのテープドライブをアーカイブファイルとして 扱う場合には、‘HOSTNAME:’で始まるファイル名を使用して下さい。 ホ スト名は、コマンドを起動するユーザが、テープドライブ使用できるホ ストの名前であることが必要です。典型的に は 、 そ の ユ ー ザ の ‘~/.rhosts’ エントリにエントリが存在するマシンであることが多いよ うです。 --force-local With -F、 -I、もしくは -O オプションを用いた場合に、コロン文字を 含むファイル名をローカルファイル名とみなして扱います。通常、コロ ン文字は、リモートホスト名とその上のローカルファイル名を区切る場 合に使用されます。 -H FORMAT, --format=FORMAT アーカイブフォーマットとして、FORMATのものを用います。FORMATの部 分に指定出来る文字列を以下に示します。これらの名前は、すべて大文 字の場合でも認識されます。コピーインモードでのデフォルトは、入力 ファイルの内容から自動的にアーカイブフォーマットを判定するもので 、コピーインモードでは、 "bin"フォーマットです。 bin binaryフォーマットです。ほとんど使われません。 odc old ASCII(old (POSIX.1) portable)フォーマットです。 newc new ASCII(new (SVR4) portable)フォーマットです。 crc crcフォーマットです。 tar (old) tar フォーマットです。 ustar POSIX.1 tar フォーマットです。GNU tar アーカイブも取り扱 うことが出来ます。POSIX.1 tar と GNU tar は、よく似ていま すが、同じではありません。 hpbin HPUXのcpioで使用されている、古いbinaryフォーマットです。( 他のcpioとは異なる形式で、デバイスファイルを保存します)。 hpodc HPUX のcpio で 使 用されているportableフォーマットです(他 のcpioとは異なる形式で、デバイスファイルを保存します)。 -i, --extract コピーインモードで走行します。 -I archive 標準入力のかわりに、指定されたアーカイブファイル名を用います。他 の マ シンのテープドライブをアーカイブファイルとして扱う場合には 、‘HOSTNAME:’で始まるファイル名を使用して下さい。ホスト名は、 コ マンドを起動するユーザが、テープドライブ使用できるホストの名前で あることが必要です。典型的には、そのユーザの ‘~/.rhosts’エントリ にエントリが存在するマシンであることが多いようです。 -k 無視されます。他のバージョンの cpio との互換性を保つためにのみ存 在します。 -l, --link ファイルをコピーするかわりに、可能な限りリンクを張ります。 -L, --dereference シンボリックリンクを参照しません。シンボリックリンクファイルをコ ピーするかわりに、シンボリックリンクファイルの指す実体のファイル をコピーします。 -m, --preserve-modification-time コピー先のファイル生成時に、コピー元のファイルの更新時刻を保持し ます。 -M MESSAGE, --message=MESSAGE バックアップ媒体(テープやフロッピーディスクなど)のボリューム終端 まで到達した場合に、MESSAGEで指定された文字列を出力します。こ の 指定をすることで、ユーザに新しい媒体の挿入指示を出すことが可能に なります。MESSAGE で指定される文字列に"%d"が含まれる 場 合 に は 、"%d"文字列は、現在の媒体通番 (1からはじまります)に置き換えられ ます。 -n, --numeric-uid-gid バーボーズモードで内容のリストを出す場合に、UIDおよびGIDを 、 そ のIDの対応するユーザ名/グループ名でなく、数字で表示します。 --no-preserve-owner コピーインモードおよびコピーパスモードにおいて、ファイルの所有者 を変更しません。これは、展開後のファイルの所有者は、実際にファイ ルの展開を行っているユーザとなることを示します。このオプションは 、スーパユーザ以外のユーザが使用する場合にはデフォルトで有効にな り ます。これは、System V のユーザが、誤ってファイルの所有権を手 放さないようにするためです。 -o, --create コピーアウトモードで走行します。 -O archive 標準出力のかわりに、指定したアーカイブファイルを用います。他のマ シ ン の テ ー プ ドライブをアーカイブファイルとして扱う場合には 、‘HOSTNAME:’で始まるファイル名を使用して下さい。ホスト名は、 コ マンドを起動するユーザが、テープドライブ使用できるホストの名前で あることが必要です。典型的には、そのユーザの ‘~/.rhosts’エントリ にエントリが存在するマシンであることが多いようです。 -p, --pass-through コピーパスモードで走行します。 -r, --rename 対話的にファイル名を変更します。 -R [user][:.][group], --owner [user][:.][group] コピーアウトモードおよびコピーパスモードにおいて、全ての生成ファ イルの所有権を指定したユーザ、グループに設定します。ユーザもしく はグループのどちらか、もしくは両方とも指定される必要があります。 グループの指定がされずに":"もしくは"."セパレータが指定された場合 には、ユーザのログイングループがグループとして設定されます。スー パーユーザのみがファイルの所有権を変更することが可能です。 -s, --swap-bytes コピーインモードにおいて、ファイル中のデータの16ビットの上位8 ビ ットと下位 8ビットを入れ換えます。 -S, --swap-halfwords コピーインモードにおいて、ファイル中のデータの32ビットの上位16ビ ットと下位 16ビットを入れ換えます。 -t, --list 入力ファイル名の一覧を出力します。 -u, --unconditional 古いファイルと新しいファイルの置換えを問い合わせることなく、全て のファイルを上書きします。 -v, --verbose 処理されたファイル名を表示します、 -t オプションが同時に指定され た場合には、‘ls -l’形式の表示を得ることが出来ます。ustarフォーマ ットのアーカイブから得られる表示においては、ローカルシステムにて 割り当てられていないユーザ名およびグループ名のファイルについては 、アーカイブ内に格納されたUIDおよびGIDの値に対応するローカルでの ユーザ名、グループ名に置き換えてその部分を表示します。 -V --dot 各ファイルを処理するごとに、"."を表示します。 --version cpio のプログラムバージョンを表示して終了します。 CPIO(1L)
CPIO(1L) CPIO(1L) NAME cpio - copy files to and from archives SYNOPSIS Copy-out mode In copy-out mode, cpio copies files into an archive. It reads a list of filenames, one per line, on the standard input, and writes the archive onto the standard output. A typical way to generate the list of filenames is with the find command; you should give find the -depth option to minimize problems with permissions on directories that are unreadable. see “Options”. cpio {-o|--create} [-0acvABLV] [-C bytes] [-H format] [-M message] [-O [[user@]host:]archive] [-F [[user@]host:]archive] [--file=[[user@]host:]archive] [--format=format] [--message=mes- sage][--null] [--reset-access-time] [--verbose] [--dot] [--append] [--block-size=blocks] [--dereference] [--io-size=bytes] [--rsh-com- mand=command] [--help] [--version] < name-list [> archive] Copy-in mode In copy-in mode, cpio copies files out of an archive or lists the archive contents. It reads the archive from the standard input. Any non-option command line arguments are shell globbing patterns; only files in the archive whose names match one or more of those patterns are copied from the archive. Unlike in the shell, an initial ‘.’ in a filename does match a wildcard at the start of a pattern, and a ‘/’ in a filename can match wildcards. If no patterns are given, all files are extracted. see “Options”. cpio {-i|--extract} [-bcdfmnrtsuvBSV] [-C bytes] [-E file] [-H format] [-M message] [-R [user][:.][group]] [-I [[user@]host:]archive] [-F [[user@]host:]archive] [--file=[[user@]host:]archive] [--make-directo- ries] [--nonmatching] [--preserve-modification-time] [--numeric-uid- gid] [--rename] [-t|--list] [--swap-bytes] [--swap] [--dot] [--uncondi- tional] [--verbose] [--block-size=blocks] [--swap-halfwords] [--io- size=bytes] [--pattern-file=file] [--format=format] [--owner=[user][:.][group]] [--no-preserve-owner] [--message=message] [--force-local] [--no-absolute-filenames] [--absolute-filenames] [--sparse] [--only-verify-crc] [--to-stdout] [--quiet] [--rsh-com- mand=command] [--help] [--version] [pattern...] [< archive] Copy-pass mode In copy-pass mode, cpio copies files from one directory tree to another, combining the copy-out and copy-in steps without actually using an archive. It reads the list of files to copy from the standard input; the directory into which it will copy them is given as a non- option argument. see “Options”. cpio {-p|--pass-through} [-0adlmuvLV] [-R [user][:.][group]] [--null] [--reset-access-time] [--make-directories] [--link] [--quiet] [--pre- serve-modification-time] [--unconditional] [--verbose] [--dot] [--dereference] [--owner=[user][:.][group]] [--no-preserve-owner] [--sparse] [--help] [--version] destination-directory < name-list DESCRIPTION GNU cpio is a tool for creating and extracting archives, or copying files from one place to another. It handles a number of cpio formats as well as reading and writing tar files. Following archive formats are supported: binary, old ASCII, new ASCII, crc, HPUX binary, HPUX old ASCII, old tar, and POSIX.1 tar. The tar format is provided for compatibility with the tar program. By default, cpio creates binary format archives, for compatibility with older cpio programs. When extracting from archives, cpio automatically recognizes which kind of archive it is reading and can read archives created on machines with a different byte-order. OPTIONS ‘-0, --null’ Read a list of filenames terminated by a null character, instead of a newline, so that files whose names contain newlines can be archived. GNU find is one way to produce a list of null-termi- nated filenames. This option may be used in copy-out and copy- pass modes. ‘-a, --reset-access-time’ Reset the access times of files after reading them, so that it does not look like they have just been read. ‘-A, --append’ Append to an existing archive. Only works in copy-out mode. The archive must be a disk file specified with the -O or -F (-file) option. ‘-b, --swap’ Swap both halfwords of words and bytes of halfwords in the data. Equivalent to -sS. This option may be used in copy-in mode. Use this option to convert 32-bit integers between big-endian and little-endian machines. ‘-B’ Set the I/O block size to 5120 bytes. Initially the block size is 512 bytes. ‘--block-size=BLOCK-SIZE’ Set the I/O block size to BLOCK-SIZE * 512 bytes. ‘-c’ Identical to “-H newc”, use the new (SVR4) portable format. If you wish the old portable (ASCII) archive format, use “-H odc” instead. ‘-C IO-SIZE, --io-size=IO-SIZE’ Set the I/O block size to IO-SIZE bytes. ‘-d, --make-directories’ Create leading directories where needed. ‘-E FILE, --pattern-file=FILE’ Read additional patterns specifying filenames to extract or list from FILE. The lines of FILE are treated as if they had been non-option arguments to cpio. This option is used in copy-in mode, ‘-f, --nonmatching’ Only copy files that do not match any of the given patterns. ‘-F, --file=archive’ Archive filename to use instead of standard input or output. To use a tape drive on another machine as the archive, use a file- name that starts with ‘HOSTNAME:’. The hostname can be preceded by a username and an ‘@’ to access the remote tape drive as that user, if you have permission to do so (typically an entry in that user’s ‘~/.rhosts’ file). ‘--force-local’ With -F, -I, or -O, take the archive file name to be a local file even if it contains a colon, which would ordinarily indi- cate a remote host name. ‘-H FORMAT, --format=FORMAT’ Use archive format FORMAT. The valid formats are listed below; the same names are also recognized in all-caps. The default in copy-in mode is to automatically detect the archive format, and in copy-out mode is ‘bin’. ‘bin’ The obsolete binary format. ‘odc’ The old (POSIX.1) portable format. ‘newc’ The new (SVR4) portable format, which supports file systems hav- ing more than 65536 i-nodes. ‘crc’ The new (SVR4) portable format with a checksum added. ‘tar’ The old tar format. ‘ustar’ The POSIX.1 tar format. Also recognizes GNU tar archives, which are similar but not identical. ‘hpbin’ The obsolete binary format used by HPUX’s cpio (which stores device files differently). ‘hpodc’ The portable format used by HPUX’s cpio (which stores device files differently). ‘-i, --extract’ Run in copy-in mode. see “Copy-in mode”. ‘-I archive’ Archive filename to use instead of standard input. To use a tape drive on another machine as the archive, use a filename that starts with ‘HOSTNAME:’. The hostname can be preceded by a username and an ‘@’ to access the remote tape drive as that user, if you have permission to do so (typically an entry in that user’s ‘~/.rhosts’ file). ‘-k’ Ignored; for compatibility with other versions of cpio. ‘-l, --link’ Link files instead of copying them, when possible. ‘-L, --dereference’ Copy the file that a symbolic link points to, rather than the symbolic link itself. ‘-m, --preserve-modification-time’ Retain previous file modification times when creating files. ‘-M MESSAGE, --message=MESSAGE’ Print MESSAGE when the end of a volume of the backup media (such as a tape or a floppy disk) is reached, to prompt the user to insert a new volume. If MESSAGE contains the string “%d”, it is replaced by the current volume number (starting at 1). ‘-n, --numeric-uid-gid’ Show numeric UID and GID instead of translating them into names when using the ‘--verbose option’. ‘--no-absolute-filenames’ Create all files relative to the current directory in copy-in mode, even if they have an absolute file name in the archive. ‘--absolute-filenames’ (default) Do not strip leading file name components that contain “..” and leading slashes from file names in copy-in mode ‘--no-preserve-owner’ Do not change the ownership of the files; leave them owned by the user extracting them. This is the default for non-root users, so that users on System V don’t inadvertently give away files. This option can be used in copy-in mode and copy-pass mode ‘-o, --create’ Run in copy-out mode. see “Copy-out mode”. ‘-O archive’ Archive filename to use instead of standard output. To use a tape drive on another machine as the archive, use a filename that starts with ‘HOSTNAME:’. The hostname can be preceded by a username and an ‘@’ to access the remote tape drive as that user, if you have permission to do so (typically an entry in that user’s ‘~/.rhosts’ file). ‘--only-verify-crc’ Verify the CRC’s of each file in the archive, when reading a CRC format archive. Don’t actually extract the files. ‘-p, --pass-through’ Run in copy-pass mode. see “Copy-pass mode”. ‘--quiet’ Do not print the number of blocks copied. ‘-r, --rename’ Interactively rename files. ‘-R [user][:.][group], --owner [user][:.][group]’ Set the ownership of all files created to the specified user and/or group in copy-out and copy-pass modes. Either the user, the group, or both, must be present. If the group is omitted but the “:” or “.” separator is given, use the given user’s login group. Only the super-user can change files’ ownership. ‘--rsh-command=COMMAND’ Notifies cpio that is should use COMMAND to communicate with remote devices. ‘-s, --swap-bytes’ Swap the bytes of each halfword (pair of bytes) in the files.This option can be used in copy-in mode. ‘-S, --swap-halfwords’ Swap the halfwords of each word (4 bytes) in the files. This option may be used in copy-in mode. ‘--sparse’ Write files with large blocks of zeros as sparse files. This option is used in copy-in and copy-pass modes. ‘-t, --list’ Print a table of contents of the input. ‘--to-stdout’ Extract files to standard output. This option may be used in copy-in mode. ‘-u, --unconditional’ Replace all files, without asking whether to replace existing newer files with older files. ‘-v, --verbose’ List the files processed, or with ‘-t’, give an ‘ls -l’ style table of contents listing. In a verbose table of contents of a ustar archive, user and group names in the archive that do not exist on the local system are replaced by the names that corre- spond locally to the numeric UID and GID stored in the archive. ‘-V, --dot’ Print a ‘.’ for each file processed. ‘--version’ Print the cpio program version number and exit. EXAMPLES When creating an archive, cpio takes the list of files to be processed from the standard input, and then sends the archive to the standard output, or to the device defined by the ‘-F’ option. Usually find or ls is used to provide this list to the standard input. In the follow- ing example you can see the possibilities for archiving the contents of a single directory. % ls | cpio -ov > directory.cpio The ‘-o’ option creates the archive, and the ‘-v’ option prints the names of the files archived as they are added. Notice that the options can be put together after a single ‘-’ or can be placed separately on the command line. The ‘>’ redirects the cpio output to the file ‘directory.cpio’. If you wanted to archive an entire directory tree, the find command can provide the file list to cpio: % find . -print -depth | cpio -ov > tree.cpio This will take all the files in the current directory, the directories below and place them in the archive tree.cpio. Again the ‘-o’ creates an archive, and the ‘-v’ option shows you the name of the files as they are archived. see “Copy-out mode”. Using the ‘.’ in the find state- ment will give you more flexibility when doing restores, as it will save file names with a relative path vice a hard wired, absolute path. The ‘-depth’ option forces ‘find’ to print of the entries in a direc- tory before printing the directory itself. This limits the effects of restrictive directory permissions by printing the directory entries in a directory before the directory name itself. Extracting an archive requires a bit more thought because cpio will not create directories by default. Another characteristic, is it will not overwrite existing files unless you tell it to. % cpio -iv < directory.cpio This will retrieve the files archived in the file directory.cpio and place them in the present directory. The ‘-i’ option extracts the archive and the ‘-v’ shows the file names as they are extracted. If you are dealing with an archived directory tree, you need to use the ‘-d’ option to create directories as necessary, something like: % cpio -idv < tree.cpio This will take the contents of the archive tree.cpio and extract it to the current directory. If you try to extract the files on top of files of the same name that already exist (and have the same or later modifi- cation time) cpio will not extract the file unless told to do so by the -u option. see “Copy-in mode”. In copy-pass mode, cpio copies files from one directory tree to another, combining the copy-out and copy-in steps without actually using an archive. It reads the list of files to copy from the standard input; the directory into which it will copy them is given as a non- option argument. see “Copy-pass mode”. % find . -depth -print0 | cpio --null -pvd new-dir The example shows copying the files of the present directory, and sub- directories to a new directory called new-dir. Some new options are the ‘-print0’ available with GNU find, combined with the ‘--null’ option of cpio. These two options act together to send file names between find and cpio, even if special characters are embedded in the file names. Another is ‘-p’, which tells cpio to pass the files it finds to the directory ‘new-dir’. BUGS The GNU folks, in general, abhor man pages, and create info documents instead. The maintainer of cpio falls into this category. Thus this man page may not be complete, nor current, and was included in the Red Hat CVS tree because man is a great tool :). REPORTING BUGS Please report bugs via https://bugzilla.redhat.com. SEE ALSO The full documentation for cpio is maintained as a Texinfo manual. If the info and cpio programs are properly installed at your site, the command info cpio should give you access to the complete manual. The online copy of the documentation is available at the following address: http://www.gnu.org/software/cpio/manual CPIO(1L)
Copyright(C) linux-cmd.com All Rights Reserved. Author Takayuki Yukawa