NAME
cp, ln, mv - copy, link or move files
SYNOPSIS
cp [ -irp ] file1 [file2 ...] target
ln [ -sif ] file1 [file2 ...] target
mv [ -if ] 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 an existing file, its contents
are destroyed, except in the ln -s case where the command will fail (use
the -i or -f option to override this behavior).
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
permissible; if not, the command exits. 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. Additionally, if target exists, then the -f option will
force the link when ln -s is specified.
For mv, if file1 is a directory the rename will occur only if file1 and
target are in the same file system. 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 cp is invoked, if target is not an existing 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 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 or 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.
The -p option will cause the modification time, permissions, owner, and
group of the target to be set to those of file1 after the file is copied.
With the -s option ln creates symbolic links. A symbolic link is a
special kind of file whose contents are the name of another file (see
symlink(2)). A symbolic link contains the name of the file to which it
is linked. Most system calls, including open(2), stat(2), and access(2),
substitute these contents when the name of a symbolic link occurs in a
pathname. This process is known as ``following'' symbolic links.
stat(2), readlink(2), symlink(2), and unlink(2) also do this
substitution, except on the last component of the pathname. Thus, they
are said not to ``follow'' symbolic links. Symbolic links may span file
systems and may refer to directories. Note that cp ``follows'' symbolic
links, while mv and ln do not ``follow'' symbolic links.
If the -i option is specified with cp, ln, or mv and target exists, the
user is prompted with the message:
overwrite target?
If the user answers with a line starting with `y', the move or copy
continues. Any other reply prevents the command from completing. When
creating soft links this warning often indicates that the user has
swapped the file and target parameters, which results in replacement of
the target file with a dangling symbolic link.
If the -r option is specified with cp and any of the source files are
directories, cp copies each subtree rooted at that name; in this case
target must be a directory.
SEE ALSO
chmod(1), cpio(1), rm(1).
WARNINGS
ln without -s 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.