Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

cp(1)

mv(1)

rm(1)

link(2)

readlink(2)

stat(2)

symlink(2)

ln(1)

Name

ln − link to a file

Syntax

ln [ −f ] [ −i ] [ −s ] name1 [name2]
ln [ −f ] [ −i ] [ −s ] name ... directory

Description

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

Given one or two arguments, ln creates a link to an existing file name1. If name2 is given, the link has that name.  The name2 may also be a directory in which to place the link.  Otherwise it is placed in the current directory.  If only the directory is specified, the link is made to the last component of name1.

Given more than two arguments, ln makes links to all the named files in the named directory. The links made have the same name as the files being linked to.

Options

−fForces existing destination pathnames to be removed before linking without prompting for confirmation. 

−iWrite a prompt to standard output requesting information for each link that would overwrite an existing file. If the response from standard input is affirmative, and if permissions allow, the link is done. The −i option has this effect even if the standard input is not a terminal. 

−sCreates a symbolic link. 

A symbolic link contains the name of the file to which it is linked.  The referenced file is used when an open() operation is performed on the link. A stat() on a symbolic link returns the linked-to file. An lstat() must be done to obtain information about the link. The readlink() call may be used to read the contents of a symbolic link. Symbolic links may span file systems and may refer to directories.

The file access mode for a symbolic link in a local file system is that of the current value of umask. The file access mode for a symbolic link in an NFS-mounted file system is 777. In either case, the system ignores the file access modes of the symbolic link and the linked-to file always behaves as defined by its file access mode.

See Also

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

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