What is ln?

ln ln command

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.

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




Contact Me

Follow me on Facebook, Twitter or Telegram:
Recommended
I learn with Educative: Educative
IT Consultancy
I'm a principal consultant with Tech Stack Solutions. I help with cloud architectrure, AWS deployments and automated management of Unix/Linux infrastructure. Get in touch!
Recent Articles
03 Sep 2024

macOS Sequoia 15.0

02 Sep 2024

Video: Has This Worked Before?

24 Mar 2024

Homelab: Mac Pro 2013 32GB

Recent Tweets