Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ ln(1) — GL2 W2.4

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

cpio(1)

ls(1)

rm(1)

chmod(2)

symlink(2)

CP(1)  —  Silicon Graphics

NAME

cp, ln, mv − copy, link or move files

SYNOPSIS

cp [ −ir ] file1 ... target
ln [ −sf ] 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 the −i option is specified with cp 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.

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 the target must be a directory. 

If mv determines that the mode of target forbids writing, it will print the mode (see chmod(2)) and read the standard input for one line (if the standard input is a terminal). If the line begins with y, the move takes place; if not, mv exits. 

Both mv and ln will allow file1 to be a directory. With mv, the directory rename will occur only if the two directories have the same parent. With ln, file1 can be a directory when using the −s option (see below). 

A link is a directory entry referring to a file; one file (together with its size, all its protection information, etc.)  may have several links to it.  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 effectively independent of the name used to reference the file.  Hard links may not span file systems and may not refer to directories. 

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 to “not 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. 

When the −f option is specified with ln or mv this stands for force.  This option overrides any mode restrictions or the −i switch. 

EXAMPLE

cp alpha beta gamma /roxanne

places copies of the three files in the directory /roxanne. 

SEE ALSO

cpio(1), ls(1), rm(1), chmod(2), symlink(2). 

BUGS

If file1 and target lie on different file systems, mv must copy the file and delete the original.  In this case the owner name becomes that of the copying process and any linking relationship with other files is lost. 

Version 2.4  —  May 08, 1986

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026