LN(1) — USER COMMANDS
NAME
ln − make links
SYNOPSIS
ln [ −f ] [ −s ] filename [ linkname ]
ln 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.
A symbolic link, which may span file systems, can be made to a filename, or to a directory, whether or not the named file exists. A symbolic link does not prevent the original file from being removed.
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.
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), lstat(2)
BUGS
Error messages print the wrong file name when the −s option is used.
Sun Release 2.0 — Last change: 1 February 1985