Blame cpio/bsdcpio.1

Packit 08bd4c
.\" Copyright (c) 2003-2007 Tim Kientzle
Packit 08bd4c
.\" All rights reserved.
Packit 08bd4c
.\"
Packit 08bd4c
.\" Redistribution and use in source and binary forms, with or without
Packit 08bd4c
.\" modification, are permitted provided that the following conditions
Packit 08bd4c
.\" are met:
Packit 08bd4c
.\" 1. Redistributions of source code must retain the above copyright
Packit 08bd4c
.\"    notice, this list of conditions and the following disclaimer.
Packit 08bd4c
.\" 2. Redistributions in binary form must reproduce the above copyright
Packit 08bd4c
.\"    notice, this list of conditions and the following disclaimer in the
Packit 08bd4c
.\"    documentation and/or other materials provided with the distribution.
Packit 08bd4c
.\"
Packit 08bd4c
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
Packit 08bd4c
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Packit 08bd4c
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
Packit 08bd4c
.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
Packit 08bd4c
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Packit 08bd4c
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
Packit 08bd4c
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
Packit 08bd4c
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
Packit 08bd4c
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
Packit 08bd4c
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
Packit 08bd4c
.\" SUCH DAMAGE.
Packit 08bd4c
.\"
Packit 08bd4c
.\" $FreeBSD$
Packit 08bd4c
.\"
Packit 08bd4c
.Dd September 16, 2014
Packit 08bd4c
.Dt CPIO 1
Packit 08bd4c
.Os
Packit 08bd4c
.Sh NAME
Packit 08bd4c
.Nm cpio
Packit 08bd4c
.Nd copy files to and from archives
Packit 08bd4c
.Sh SYNOPSIS
Packit 08bd4c
.Nm
Packit 08bd4c
.Fl i
Packit 08bd4c
.Op Ar options
Packit 08bd4c
.Op Ar pattern ...
Packit 08bd4c
.Op Ar < archive
Packit 08bd4c
.Nm
Packit 08bd4c
.Fl o
Packit 08bd4c
.Op Ar options
Packit 08bd4c
.Ar < name-list
Packit 08bd4c
.Op Ar > archive
Packit 08bd4c
.Nm
Packit 08bd4c
.Fl p
Packit 08bd4c
.Op Ar options
Packit 08bd4c
.Ar dest-dir
Packit 08bd4c
.Ar < name-list
Packit 08bd4c
.Sh DESCRIPTION
Packit 08bd4c
.Nm
Packit 08bd4c
copies files between archives and directories.
Packit 08bd4c
This implementation can extract from tar, pax, cpio, zip, jar, ar,
Packit 08bd4c
and ISO 9660 cdrom images and can create tar, pax, cpio, ar,
Packit 08bd4c
and shar archives.
Packit 08bd4c
.Pp
Packit 08bd4c
The first option to
Packit 08bd4c
.Nm
Packit 08bd4c
is a mode indicator from the following list:
Packit 08bd4c
.Bl -tag -compact -width indent
Packit 08bd4c
.It Fl i
Packit 08bd4c
Input.
Packit 08bd4c
Read an archive from standard input (unless overridden) and extract the
Packit 08bd4c
contents to disk or (if the
Packit 08bd4c
.Fl t
Packit 08bd4c
option is specified)
Packit 08bd4c
list the contents to standard output.
Packit 08bd4c
If one or more file patterns are specified, only files matching
Packit 08bd4c
one of the patterns will be extracted.
Packit 08bd4c
.It Fl o
Packit 08bd4c
Output.
Packit 08bd4c
Read a list of filenames from standard input and produce a new archive
Packit 08bd4c
on standard output (unless overridden) containing the specified items.
Packit 08bd4c
.It Fl p
Packit 08bd4c
Pass-through.
Packit 08bd4c
Read a list of filenames from standard input and copy the files to the
Packit 08bd4c
specified directory.
Packit 08bd4c
.El
Packit 08bd4c
.Pp
Packit 08bd4c
.Sh OPTIONS
Packit 08bd4c
Unless specifically stated otherwise, options are applicable in
Packit 08bd4c
all operating modes.
Packit 08bd4c
.Bl -tag -width indent
Packit 08bd4c
.It Fl 0 , Fl Fl null
Packit 08bd4c
Read filenames separated by NUL characters instead of newlines.
Packit 08bd4c
This is necessary if any of the filenames being read might contain newlines.
Packit 08bd4c
.It Fl A
Packit 08bd4c
(o mode only)
Packit 08bd4c
Append to the specified archive.
Packit 08bd4c
(Not yet implemented.)
Packit 08bd4c
.It Fl a
Packit 08bd4c
(o and p modes)
Packit 08bd4c
Reset access times on files after they are read.
Packit 08bd4c
.It Fl B
Packit 08bd4c
(o mode only)
Packit 08bd4c
Block output to records of 5120 bytes.
Packit 08bd4c
.It Fl C Ar size
Packit 08bd4c
(o mode only)
Packit 08bd4c
Block output to records of
Packit 08bd4c
.Ar size
Packit 08bd4c
bytes.
Packit 08bd4c
.It Fl c
Packit 08bd4c
(o mode only)
Packit 08bd4c
Use the old POSIX portable character format.
Packit 08bd4c
Equivalent to
Packit 08bd4c
.Fl Fl format Ar odc .
Packit 08bd4c
.It Fl d , Fl Fl make-directories
Packit 08bd4c
(i and p modes)
Packit 08bd4c
Create directories as necessary.
Packit 08bd4c
.It Fl E Ar file
Packit 08bd4c
(i mode only)
Packit 08bd4c
Read list of file name patterns from
Packit 08bd4c
.Ar file
Packit 08bd4c
to list and extract.
Packit 08bd4c
.It Fl F Ar file , Fl Fl file Ar file
Packit 08bd4c
Read archive from or write archive to
Packit 08bd4c
.Ar file .
Packit 08bd4c
.It Fl f Ar pattern
Packit 08bd4c
(i mode only)
Packit 08bd4c
Ignore files that match
Packit 08bd4c
.Ar pattern .
Packit 08bd4c
.It Fl H Ar format , Fl Fl format Ar format
Packit 08bd4c
(o mode only)
Packit 08bd4c
Produce the output archive in the specified format.
Packit 08bd4c
Supported formats include:
Packit 08bd4c
.Pp
Packit 08bd4c
.Bl -tag -width "iso9660" -compact
Packit 08bd4c
.It Ar cpio
Packit 08bd4c
Synonym for
Packit 08bd4c
.Ar odc .
Packit 08bd4c
.It Ar newc
Packit 08bd4c
The SVR4 portable cpio format.
Packit 08bd4c
.It Ar odc
Packit 08bd4c
The old POSIX.1 portable octet-oriented cpio format.
Packit 08bd4c
.It Ar pax
Packit 08bd4c
The POSIX.1 pax format, an extension of the ustar format.
Packit 08bd4c
.It Ar ustar
Packit 08bd4c
The POSIX.1 tar format.
Packit 08bd4c
.El
Packit 08bd4c
.Pp
Packit 08bd4c
The default format is
Packit 08bd4c
.Ar odc .
Packit 08bd4c
See
Packit 08bd4c
.Xr libarchive-formats 5
Packit 08bd4c
for more complete information about the
Packit 08bd4c
formats currently supported by the underlying
Packit 08bd4c
.Xr libarchive 3
Packit 08bd4c
library.
Packit 08bd4c
.It Fl h , Fl Fl help
Packit 08bd4c
Print usage information.
Packit 08bd4c
.It Fl I Ar file
Packit 08bd4c
Read archive from
Packit 08bd4c
.Ar file .
Packit 08bd4c
.It Fl i , Fl Fl extract
Packit 08bd4c
Input mode.
Packit 08bd4c
See above for description.
Packit 08bd4c
.It Fl Fl insecure
Packit 08bd4c
(i and p mode only)
Packit 08bd4c
Disable security checks during extraction or copying.
Packit 08bd4c
This allows extraction via symbolic links, absolute paths,
Packit 08bd4c
and path names containing
Packit 08bd4c
.Sq ..
Packit 08bd4c
in the name.
Packit 08bd4c
.It Fl J , Fl Fl xz
Packit 08bd4c
(o mode only)
Packit 08bd4c
Compress the file with xz-compatible compression before writing it.
Packit 08bd4c
In input mode, this option is ignored; xz compression is recognized
Packit 08bd4c
automatically on input.
Packit 08bd4c
.It Fl j
Packit 08bd4c
Synonym for
Packit 08bd4c
.Fl y .
Packit 08bd4c
.It Fl L
Packit 08bd4c
(o and p modes)
Packit 08bd4c
All symbolic links will be followed.
Packit 08bd4c
Normally, symbolic links are archived and copied as symbolic links.
Packit 08bd4c
With this option, the target of the link will be archived or copied instead.
Packit 08bd4c
.It Fl l , Fl Fl link
Packit 08bd4c
(p mode only)
Packit 08bd4c
Create links from the target directory to the original files,
Packit 08bd4c
instead of copying.
Packit 08bd4c
.It Fl Fl lrzip
Packit 08bd4c
(o mode only)
Packit 08bd4c
Compress the resulting archive with
Packit 08bd4c
.Xr lrzip 1 .
Packit 08bd4c
In input mode, this option is ignored.
Packit 08bd4c
.It Fl Fl lz4
Packit 08bd4c
(o mode only)
Packit 08bd4c
Compress the archive with lz4-compatible compression before writing it.
Packit 08bd4c
In input mode, this option is ignored; lz4 compression is recognized
Packit 08bd4c
automatically on input.
Packit 08bd4c
.It Fl Fl lzma
Packit 08bd4c
(o mode only)
Packit 08bd4c
Compress the file with lzma-compatible compression before writing it.
Packit 08bd4c
In input mode, this option is ignored; lzma compression is recognized
Packit 08bd4c
automatically on input.
Packit 08bd4c
.It Fl Fl lzop
Packit 08bd4c
(o mode only)
Packit 08bd4c
Compress the resulting archive with
Packit 08bd4c
.Xr lzop 1 .
Packit 08bd4c
In input mode, this option is ignored.
Packit 08bd4c
.It Fl Fl passphrase Ar passphrase
Packit 08bd4c
The
Packit 08bd4c
.Pa passphrase
Packit 08bd4c
is used to extract or create an encrypted archive.
Packit 08bd4c
Currently, zip is only a format that
Packit 08bd4c
.Nm
Packit 08bd4c
can handle encrypted archives.
Packit 08bd4c
You shouldn't use this option unless you realize how insecure
Packit 08bd4c
use of this option is.
Packit 08bd4c
.It Fl m , Fl Fl preserve-modification-time
Packit 08bd4c
(i and p modes)
Packit 08bd4c
Set file modification time on created files to match
Packit 08bd4c
those in the source.
Packit 08bd4c
.It Fl n , Fl Fl numeric-uid-gid
Packit 08bd4c
(i mode, only with
Packit 08bd4c
.Fl t )
Packit 08bd4c
Display numeric uid and gid.
Packit 08bd4c
By default,
Packit 08bd4c
.Nm
Packit 08bd4c
displays the user and group names when they are provided in the
Packit 08bd4c
archive, or looks up the user and group names in the system
Packit 08bd4c
password database.
Packit 08bd4c
.It Fl Fl no-preserve-owner
Packit 08bd4c
(i mode only)
Packit 08bd4c
Do not attempt to restore file ownership.
Packit 08bd4c
This is the default when run by non-root users.
Packit 08bd4c
.It Fl O Ar file
Packit 08bd4c
Write archive to
Packit 08bd4c
.Ar file .
Packit 08bd4c
.It Fl o , Fl Fl create
Packit 08bd4c
Output mode.
Packit 08bd4c
See above for description.
Packit 08bd4c
.It Fl p , Fl Fl pass-through
Packit 08bd4c
Pass-through mode.
Packit 08bd4c
See above for description.
Packit 08bd4c
.It Fl Fl preserve-owner
Packit 08bd4c
(i mode only)
Packit 08bd4c
Restore file ownership.
Packit 08bd4c
This is the default when run by the root user.
Packit 08bd4c
.It Fl Fl quiet
Packit 08bd4c
Suppress unnecessary messages.
Packit 08bd4c
.It Fl R Oo user Oc Ns Oo : Oc Ns Oo group Oc , Fl Fl owner Oo user Oc Ns Oo : Oc Ns Oo group Oc
Packit 08bd4c
Set the owner and/or group on files in the output.
Packit 08bd4c
If group is specified with no user
Packit 08bd4c
(for example,
Packit 08bd4c
.Fl R Ar :wheel )
Packit 08bd4c
then the group will be set but not the user.
Packit 08bd4c
If the user is specified with a trailing colon and no group
Packit 08bd4c
(for example,
Packit 08bd4c
.Fl R Ar root: )
Packit 08bd4c
then the group will be set to the user's default group.
Packit 08bd4c
If the user is specified with no trailing colon, then
Packit 08bd4c
the user will be set but not the group.
Packit 08bd4c
In
Packit 08bd4c
.Fl i
Packit 08bd4c
and
Packit 08bd4c
.Fl p
Packit 08bd4c
modes, this option can only be used by the super-user.
Packit 08bd4c
(For compatibility, a period can be used in place of the colon.)
Packit 08bd4c
.It Fl r
Packit 08bd4c
(All modes.)
Packit 08bd4c
Rename files interactively.
Packit 08bd4c
For each file, a prompt is written to
Packit 08bd4c
.Pa /dev/tty
Packit 08bd4c
containing the name of the file and a line is read from
Packit 08bd4c
.Pa /dev/tty .
Packit 08bd4c
If the line read is blank, the file is skipped.
Packit 08bd4c
If the line contains a single period, the file is processed normally.
Packit 08bd4c
Otherwise, the line is taken to be the new name of the file.
Packit 08bd4c
.It Fl t , Fl Fl list
Packit 08bd4c
(i mode only)
Packit 08bd4c
List the contents of the archive to stdout;
Packit 08bd4c
do not restore the contents to disk.
Packit 08bd4c
.It Fl u , Fl Fl unconditional
Packit 08bd4c
(i and p modes)
Packit 08bd4c
Unconditionally overwrite existing files.
Packit 08bd4c
Ordinarily, an older file will not overwrite a newer file on disk.
Packit 08bd4c
.It Fl V , Fl Fl dot
Packit 08bd4c
Print a dot to stderr for each file as it is processed.
Packit 08bd4c
Superseded by
Packit 08bd4c
.Fl v .
Packit 08bd4c
.It Fl v , Fl Fl verbose
Packit 08bd4c
Print the name of each file to stderr as it is processed.
Packit 08bd4c
With
Packit 08bd4c
.Fl t ,
Packit 08bd4c
provide a detailed listing of each file.
Packit 08bd4c
.It Fl Fl version
Packit 08bd4c
Print the program version information and exit.
Packit 08bd4c
.It Fl y
Packit 08bd4c
(o mode only)
Packit 08bd4c
Compress the archive with bzip2-compatible compression before writing it.
Packit 08bd4c
In input mode, this option is ignored;
Packit 08bd4c
bzip2 compression is recognized automatically on input.
Packit 08bd4c
.It Fl Z
Packit 08bd4c
(o mode only)
Packit 08bd4c
Compress the archive with compress-compatible compression before writing it.
Packit 08bd4c
In input mode, this option is ignored;
Packit 08bd4c
compression is recognized automatically on input.
Packit 08bd4c
.It Fl z
Packit 08bd4c
(o mode only)
Packit 08bd4c
Compress the archive with gzip-compatible compression before writing it.
Packit 08bd4c
In input mode, this option is ignored;
Packit 08bd4c
gzip compression is recognized automatically on input.
Packit 08bd4c
.El
Packit 08bd4c
.Sh EXIT STATUS
Packit 08bd4c
.Ex -std
Packit 08bd4c
.Sh ENVIRONMENT
Packit 08bd4c
The following environment variables affect the execution of
Packit 08bd4c
.Nm :
Packit 08bd4c
.Bl -tag -width ".Ev BLOCKSIZE"
Packit 08bd4c
.It Ev LANG
Packit 08bd4c
The locale to use.
Packit 08bd4c
See
Packit 08bd4c
.Xr environ 7
Packit 08bd4c
for more information.
Packit 08bd4c
.It Ev TZ
Packit 08bd4c
The timezone to use when displaying dates.
Packit 08bd4c
See
Packit 08bd4c
.Xr environ 7
Packit 08bd4c
for more information.
Packit 08bd4c
.El
Packit 08bd4c
.Sh EXAMPLES
Packit 08bd4c
The
Packit 08bd4c
.Nm
Packit 08bd4c
command is traditionally used to copy file hierarchies in conjunction
Packit 08bd4c
with the
Packit 08bd4c
.Xr find 1
Packit 08bd4c
command.
Packit 08bd4c
The first example here simply copies all files from
Packit 08bd4c
.Pa src
Packit 08bd4c
to
Packit 08bd4c
.Pa dest :
Packit 08bd4c
.Dl Nm find Pa src | Nm Fl pmud Pa dest
Packit 08bd4c
.Pp
Packit 08bd4c
By carefully selecting options to the
Packit 08bd4c
.Xr find 1
Packit 08bd4c
command and combining it with other standard utilities,
Packit 08bd4c
it is possible to exercise very fine control over which files are copied.
Packit 08bd4c
This next example copies files from
Packit 08bd4c
.Pa src
Packit 08bd4c
to
Packit 08bd4c
.Pa dest
Packit 08bd4c
that are more than 2 days old and whose names match a particular pattern:
Packit 08bd4c
.Dl Nm find Pa src Fl mtime Ar +2 | Nm grep foo[bar] | Nm Fl pdmu Pa dest
Packit 08bd4c
.Pp
Packit 08bd4c
This example copies files from
Packit 08bd4c
.Pa src
Packit 08bd4c
to
Packit 08bd4c
.Pa dest
Packit 08bd4c
that are more than 2 days old and which contain the word
Packit 08bd4c
.Do foobar Dc :
Packit 08bd4c
.Dl Nm find Pa src Fl mtime Ar +2 | Nm xargs Nm grep -l foobar | Nm Fl pdmu Pa dest
Packit 08bd4c
.Sh COMPATIBILITY
Packit 08bd4c
The mode options i, o, and p and the options
Packit 08bd4c
a, B, c, d, f, l, m, r, t, u, and v comply with SUSv2.
Packit 08bd4c
.Pp
Packit 08bd4c
The old POSIX.1 standard specified that only
Packit 08bd4c
.Fl i ,
Packit 08bd4c
.Fl o ,
Packit 08bd4c
and
Packit 08bd4c
.Fl p
Packit 08bd4c
were interpreted as command-line options.
Packit 08bd4c
Each took a single argument of a list of modifier
Packit 08bd4c
characters.
Packit 08bd4c
For example, the standard syntax allows
Packit 08bd4c
.Fl imu
Packit 08bd4c
but does not support
Packit 08bd4c
.Fl miu
Packit 08bd4c
or
Packit 08bd4c
.Fl i Fl m Fl u ,
Packit 08bd4c
since
Packit 08bd4c
.Ar m
Packit 08bd4c
and
Packit 08bd4c
.Ar u
Packit 08bd4c
are only modifiers to
Packit 08bd4c
.Fl i ,
Packit 08bd4c
they are not command-line options in their own right.
Packit 08bd4c
The syntax supported by this implementation is backwards-compatible
Packit 08bd4c
with the standard.
Packit 08bd4c
For best compatibility, scripts should limit themselves to the
Packit 08bd4c
standard syntax.
Packit 08bd4c
.Sh SEE ALSO
Packit 08bd4c
.Xr bzip2 1 ,
Packit 08bd4c
.Xr tar 1 ,
Packit 08bd4c
.Xr gzip 1 ,
Packit 08bd4c
.Xr mt 1 ,
Packit 08bd4c
.Xr pax 1 ,
Packit 08bd4c
.Xr libarchive 3 ,
Packit 08bd4c
.Xr cpio 5 ,
Packit 08bd4c
.Xr libarchive-formats 5 ,
Packit 08bd4c
.Xr tar 5
Packit 08bd4c
.Sh STANDARDS
Packit 08bd4c
There is no current POSIX standard for the cpio command; it appeared
Packit 08bd4c
in
Packit 08bd4c
.St -p1003.1-96
Packit 08bd4c
but was dropped from
Packit 08bd4c
.St -p1003.1-2001 .
Packit 08bd4c
.Pp
Packit 08bd4c
The cpio, ustar, and pax interchange file formats are defined by
Packit 08bd4c
.St -p1003.1-2001
Packit 08bd4c
for the pax command.
Packit 08bd4c
.Sh HISTORY
Packit 08bd4c
The original
Packit 08bd4c
.Nm cpio
Packit 08bd4c
and
Packit 08bd4c
.Nm find
Packit 08bd4c
utilities were written by Dick Haight
Packit 08bd4c
while working in AT&T's Unix Support Group.
Packit 08bd4c
They first appeared in 1977 in PWB/UNIX 1.0, the
Packit 08bd4c
.Dq Programmer's Work Bench
Packit 08bd4c
system developed for use within AT&T.
Packit 08bd4c
They were first released outside of AT&T as part of System III Unix in 1981.
Packit 08bd4c
As a result,
Packit 08bd4c
.Nm cpio
Packit 08bd4c
actually predates
Packit 08bd4c
.Nm tar ,
Packit 08bd4c
even though it was not well-known outside of AT&T until some time later.
Packit 08bd4c
.Pp
Packit 08bd4c
This is a complete re-implementation based on the
Packit 08bd4c
.Xr libarchive 3
Packit 08bd4c
library.
Packit 08bd4c
.Sh BUGS
Packit 08bd4c
The cpio archive format has several basic limitations:
Packit 08bd4c
It does not store user and group names, only numbers.
Packit 08bd4c
As a result, it cannot be reliably used to transfer
Packit 08bd4c
files between systems with dissimilar user and group numbering.
Packit 08bd4c
Older cpio formats limit the user and group numbers to
Packit 08bd4c
16 or 18 bits, which is insufficient for modern systems.
Packit 08bd4c
The cpio archive formats cannot support files over 4 gigabytes,
Packit 08bd4c
except for the
Packit 08bd4c
.Dq odc
Packit 08bd4c
variant, which can support files up to 8 gigabytes.