CP(1) (Essential Utilities) CP(1)
NAME
cp, ln, mv - copy, link or move files
SYNOPSIS
cp file1 [ file2 ...] target
ln [ -f ] [ -s ] file1 [ file2 ...] target
mv [ -f ] file1 [ file2 ...] target
DESCRIPTION
file1 is copied (linked, moved) to target. Under no
circumstance can file1 and target be the same (take care
when using sh(1) metacharacters). If target is a directory,
then one or more files are copied (linked, moved) to that
directory. If target is a file, its contents are destroyed.
If mv or ln determines that the mode of target forbids
writing, it will print the mode [see chmod(2)], ask for a
response, and read the standard input for one line; if the
line begins with y, the mv or ln occurs, if permissable; if
not, the command exits. For mv, when the parent directory
of file1 is writable and has the sticky bit set, one or more
of the following conditions must be true:
the user must own the file
the user must own the directory
the file must be writable by the user
the user must be the super-user
When the -f option is used or if the standard input is not a
terminal, no questions are asked and the mv or ln is done.
Only mv will allow file1 to be a directory, in which case,
the directory rename will occur only if the two directories
have the same parent; file1 is renamed target. If file1 is a
file and target is a link to another file with links, the
other links remain and target becomes a new file.
When using cp, if target is not a file, a new file is
created which has the same mode as file1 except that the
sticky bit is not set unless you are super-user; the owner
Page 1 May 1989
CP(1) (Essential Utilities) CP(1)
and group of target are those of the user. If target is a
file, copying a file into target does not change its mode,
owner, nor group. The last modification time of target (and
last access time, if target did not exist) and the last
access time of file1 are set to the time the copy was made.
If target is a link to a file, all links remain and the file
is changed.
There are two kinds of links: hard links and symbolic links.
By default, ln makes hard links. A hard link to a file is
indistinguishable from the original directory entry; any
changes to a file are effective independent of the name used
to reference the file. Hard links may not span file systems
and may not refer to directories.
The -s option causes ln to create symbolic links. A symbolic
link contains the name of the file to which it is linked.
The referenced file is used when an open(2) is performed on
the link. A stat(2) on a symbolic link will return the
linked-to file. An lstat(2) must be done to obtain
information about the link. The readlink(2) call may be used
to read the contents of a symbolic link. Symbolic links may
span file systems and may refer to directories.
SEE ALSO
chmod(1), cpio(1), lstat(2), readlink(2), rm(1), symlink(2).
WARNINGS
ln will not link across file systems. This restriction is
necessary because file systems can be added and removed.
BUGS
If file1 and target lie on different file systems, mv must
copy the file and delete the original. In this case any
linking relationship with other files is lost.
Page 2 May 1989