Ln (Unix) - Specification

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. However, we still have access to the original data through the hardlink:

~/directory $ cat hardlink.file This is a file

You will notice that when we deleted the original file, the hardlink didn't vanish. Similarly, if we had deleted the softlink, the original file wouldn't have vanished.

Read more about this topic:  Ln (Unix)