DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Directory and file management

Archiving commands

The cpio(1) command copies file archives usually to or from a storage medium such as tape, disk, or diskette. By default, cpio does not follow symbolic links, unless the -L option used with the -o and -p options to indicates that symbolic links should be followed. Note that this option is not valid with the -i option.

Normally, a user invokes the find(1) command to produce a list of filenames and pipes this into the cpio(1) command to create an archive of the files listed. The find(1) command also has a new option -follow to indicate that symbolic links should be followed. If a user invokes find(1) with the -follow option, then cpio(1) must also be invoked with its new option -L to indicate that it too should follow symbolic links.

When evaluating the output from find(1), following or not following symbolic links only makes a difference when a symbolic link to a directory is encountered. For example, if /usr/jan/symd is a symbolic link to the directory ../joe/test and files test1 and test2 are in directory /usr/joe/test, the output of a find starting from /usr/jan includes the file /usr/jan/symd if symbolic links are not followed, but includes /usr/jan/symd/test1 and /usr/jan/symd/test2 as well as /usr/jan/symd if symbolic links are followed.

If the user wants to preserve the structure of the directories being archived, it is recommended that symbolic links not be followed on both commands. (This is the default.) When this is done symbolic links will be preserved and the directory hierarchy will be duplicated as it was. If the user is more concerned that the contents of the files be saved, then the user should use the -L option to cpio(1) and the -follow option to find(1) to follow symbolic links.


CAUTION: The user should take care not to mix modes, that is, the user should either follow or not follow symbolic links for both cpio(1) and find(1). If modes are mixed, an archive will be created but the resulting hierarchy created by cpio -i may exhibit unexpected and undesirable results.

The -i option to cpio(1) copies symbolic links as is. So if a user creates an archive to be read in on a pre-System V Release 4 system, it may be more useful to follow symbolic links because System V prior to Release 4 lacked symbolic links and the result of copying in a symbolic link will be a regular file containing the pathname of the referenced file.


Next topic: Summary of UNIX system files & directories
Previous topic: Symbolic links with NFS: example 2

© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 27 April 2004