ln (Unix)
With ln another directory entry is created for a file on Unix-like systems . The utility can create both “ hard ” and “ symbolic ” links . 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 ln
program 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 cp
and mv
used 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
-
Utilities with similar syntax / function:
-
cp (Unix) - "content" of files for user programs receives additional storage space of a similar size (without option
-s
) ... - mv (Unix) - previous path name becomes invalid ...
-
cp (Unix) - "content" of files for user programs receives additional storage space of a similar size (without option
- Paragraph file operations in the article Unix commands
Web links
-
ln
: link files - Open Group Base Specification
- as well as the utilities
link
,unlink
andsymlink
, - and the function calls
link()
,unlink()
andsymlink()
.
-
ln(1)
: Creating links between files - Debian GNU / Linux executables or shell commands man page
- and
link(2)
,unlink(2)
,symlink(2)
andsymlink(7)
- and
link(2)
,unlink(2)
,symlink(2)
andsymlink(7)