Open Access Articles- Top Results for Ln (Unix)

ln (Unix)

ln is a standard Unix command used to create links (link) to files.

Link files

Links allow more than one file name to refer to the same file, elsewhere.

There are two types of links, both of which are created by ln:

  1. symbolic links, which refer to a symbolic path indicating the abstract location of another file; and
  2. hard links, which refer to the specific location of physical data.

These links behave differently when the source of the link (what is being linked to) is moved or removed. Symbolic links are not updated (they merely contain a string which is the pathname of its target); hard links always refer to the source, even if moved or removed.


The Single Unix Specification (SUS) specifies the behaviour that a link or links (either symbolic or hard) will be created where specified that will link to the target file (or directory) specified.

More precisely, ln can be invoked in one of two ways: two arguments—first an argument specifying the source file then the target, or multiple (greater than two) arguments, specifying firstly a number of source files, then a directory in which all the links are to be created. In the latter invocation, the names of the links will be that of the source file. This invocation will be assumed if the last argument is a directory. If invoked in the latter form, ln's behaviour is not specified (it is implementation-defined).

ln is specified to use behaviour identical to that of the standard unlink() and link() functions. The original file can still be accessed through the hardlink:

$ cat hardlink.file
This is a file

Multiple hard links can be made to the same file. Each hard link increments a reference count; a file is not deleted until its reference count reaches zero.

See also

External links

Manual pages