LN(1) — USER COMMANDS
NAME
ln − make links
SYNOPSIS
ln [ −f ] [ −s ] name1 [ name2 ]
ln name ... directory
DESCRIPTION
A link is a directory entry referring to a file or another directory; the same file or directory (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.
Ln makes hard links by default. A hard link to a file or directory is indistinguishable from the original directory entry; any changes to a file or directory are effective independent of the name used to reference the file or directory. Hard links may not span file systems.
Given one or two arguments, ln creates a link to an existing file or directory name1. If name2 is given, the link has that name; name2 may also be a directory in which to place the link; otherwise it is placed in the current directory. If name2 is omitted or is a directory, the link made will have the same name as the last component of name1.
Given more than two arguments, the last argument must be the name of a directory. In this case, ln makes links to all the named files in the named directory. The links made will have the same name as the files being linked to.
OPTIONS
−f Force a hard link to a directory. The −f option is only available to the super-user.
−s Create 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(2) operation is performed on the link. A stat(2) on a symbolic link returns 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.
EXAMPLES
The commands below illustrate the effects of the different forms of the ln command.
mars% ls −FSee what files we’ve got
grabjones/
mars% ls −F jonesSee what files there are in jones
houseOne file
mars% ln grabtry to link a file in the same directory
./grab: File existsSorry — can’t link a file to itself
mars% ln jones/houselink a file from another directory to here
mars% ls −F
grabhousejones/
mars% ln grab holdlink a file to another name in this directory
mars% ls −F
grabholdhousejones/
mars% ln grab hold joneslink files from here to jones
mars% ls −F jones
grabholdhouse
mars%
SEE ALSO
rm(1), cp(1), mv(1), link(2), readlink(2), stat(2), symlink(2)
BUGS
Error messages print the wrong file name when the −s option is used.
Sun Release 1.1 — Last change: 26 October 1983