Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

rm(1)

cp(1)

mv(1)

link(2)

readlink(2)

stat(2)

symlink(2)

lstat(2)

LN(1)  —  USER COMMANDS

NAME

ln − make links

SYNOPSIS

ln [ −f ] [ −s ] filename [ linkname ]
ln [ −f ] [ −s ] filename ... directory

DESCRIPTION

ln assigns an additional name (directory entry), called a link, to a file or directory.  Several links may be assigned to a file at any one time. The number of links does not affect other attributes such as size, protections, data, etc. There are two kinds of links: hard links and symbolic links.

A hard link, which is the default, can only be made to an existing file.  Only the superuser can make a hard link to a directory.  To remove a file with more than one hard link, all such links (including the name by which it was created) must be removed.  Hard links may not span file systems. 

ln can also make symbolic links.  A symbolic link contains the name of the file or directory to which it is linked.  The referenced file or directory is used when an open(2V) operation is performed on the link.  A stat on a symbolic link returns the linked-to file; an lstat(2) must be done to obtain information about the link itself.  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. 

filename is the original name of the file or directory to be linked.  linkname is the new name to be associated with the file or filename.  If linkname is omitted, the last  component of the original pathname is used.  directory is a directory in which to place the link.  When a directory is specified, ln uses the last component of each original pathname as the name of each link. 

OPTIONS

−f Force a hard link to a directory, — this option is only available to the superuser. 

−s Create symbolic links. 

EXAMPLES

The commands below illustrate the effects of the different forms of the ln command. 

tutorial%  ls  −FSee what files we’ve got
grabjones/
tutorial%  ls  −F  jonesSee what files there are in jones
houseOne file
tutorial%  ln  grabtry to link a file in the same directory
./grab: File existsSorry — can’t link a file to itself
tutorial%  ln  jones/houselink a file from another directory to here
tutorial%  ls  −F
grabhousejones/
tutorial%  ln  grab  holdlink a file to another name in this directory
tutorial%  ls  −F
grabholdhousejones/
tutorial%  ln  grab  hold  joneslink files from here to jones
tutorial%  ls  −F  jones
grabholdhouse
tutorial%

SEE ALSO

rm(1), cp(1), mv(1), link(2), readlink(2), stat(2), symlink(2), lstat(2)

Sun Release 3.2  —  Last change: 23 September 1985

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