What is ln?

ln command.jpg

In Unix, ln means¬†ln command¬†that is used for linking files and directories to each other. ln command allows any number of new names to be created, all pointing to the same file or directory. You can then use any of these names to operate with the original file’s data.

ALSO: ln could mean natural logarithm. Specifically, the natural logarithm of x is generally written as ln x.

Two types of links ln can create

File links are just two of the common Unix file types:

  • hard link – association of a new file name with the inode for the original file
  • symbolic link (symlink) – association of a new file with the path to the original file

The biggest difference is that hard link points to the actual file data, and removing it would remove that data (similar to removing the original file it’s pointing to), while symlink will only remove the pointer to the original file, but not the file itself.

So hard link is a new name, but not a new filesystem entry. Symlink is both new name and a new filesystem entry, that’s why it can be removed without removing original file. While we’re on this topic, the original file can also be removed without touch symlink – this would result in the broken symlink (beause it will be pointing nowhere).

By default, ln command creates hard links.

See Also