ln (Unix)

from Wikipedia, the free encyclopedia

With ln another directory entry is created for a file on Unix-like systems . The utility can create both “ hard ” and “ symboliclinks . These links are removed with the command or . The command-line programs use, the POSIX functions , and the C standard library . rm(1)unlink(1)link()unlink()symlink()

A lnprogram was already present in the first versions of AT&T UNIX .

use

Use with a parameter

ln must always be called with at least one argument . The first argument always represents the source file, i.e. H. the name of the existing file . If no second argument is given, a link with the same name is created in the current working directory to the file. A call like

ln pfad/zur/quelldatei

creates a link called source file in the current working directory . A call like leads to an error because this would create a link with the same name to the existing file in the current directory, but two files in a folder are not allowed to have the same name. ln quelldatei

Use with multiple parameters

When used with exactly two arguments, the first represents the source file, while the second argument specifies the name of the target file to be created. The syntax is therefore:

ln quelldatei [zieldatei]

A use with more than two arguments is interpreted in such a way that first several source data are specified to be linked to, and as the last argument a directory in which the links of the same name to these source files are to be created. A call like

ln datei1 datei2 datei3 zielverzeichnis/

creates three hard links in the target directory with the names file1 , file2 and file3 .

When using at least two parameters, it should be noted that the order and meaning of the parameters works absolutely analogously to the equally common Unix commands cpand mvused to copy or move files or folders.

Generation of symbolic links

Like almost every Unix command, ln also takes additional parameters in the form . One of the most important and most frequently used parameters is , with which symbolic links can be created instead of hard links. Due to the limitations of hard links, which neither point to directories nor can overcome partition boundaries, symbolic links are used very often in modern Unix derivatives, for example Linux . ln -parameter ...-s

See also

Web links

as well as the utilities link, unlinkand symlink,
and the function calls link(), unlink()and symlink().
and link(2), unlink(2), symlink(2)andsymlink(7)
and link(2), unlink(2), symlink(2)andsymlink(7)