|
ln is a standard Unix program used to create links (link) between files.
Link files Links allow more than one file to refer to the same file, elsewhere. There are two types of links, both of which are created by ln: 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. Specification 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. Usage The SUS mandates for ln two options: -f, which will force removal of existing files to allow the link to be created, and -s, to specify symbolic links. Other Unix and Unix-like operating systems may add extra options. GNU ln adds options such as -b to back up files before creating links, -v to print out the names of each files before links are created, and others. BSD ln adds -h, preventing ln from descending into targets whose symlinks point to directories Examples ln xyz abc would have the effect of creating a hard link called abc that points to the same data as the existing file xyz. See also Manual pages | ||||||||
|
| |||||||||
![]() |
|
| |