Links in Linux are like shortcuts created in windows (.lnk files). In Linux there are two types of links that can be created, they are hard and soft links.

Before getting closer to links, a understanding of how files are stored in Linux is good,

inode – All files and directories in Linux are stores with a unique number called inode, this inode is also a data structure that holds the attributes of the file/directory

Hard Link

The created link takes the inode of the original file

Advantages

  • Any change (attribute) done to the original copy will reflect in the link.
  • Link will still point to the file, if the source file is deleted.

Limitations

  • Cannot go beyond file systems boundaries.
  • Cannot link directories (This limitation is to prevent endless recursive loop)

Soft Link (Symbolic link)

Holds the abstract location of the file.

Advantages

  • They have a different inode (they are like new files)
  • They can link to directories also.
  • Can link across file systems.
  • The link can have a different file permission than the source.

Limitations

  • Does not reflect the attributes of the source. (Can be called as limitation also)
  • Source if moved or removed, the link will fail.

Some experiments

Hard and Soft links tried

Hard and Soft links tried

Share

Related posts:

  1. dirname (Linux command)
  2. strings (Linux Command)
  3. groupmod (Linux command)
  4. Installing Linux(ubuntu) from a USB Diskete
  5. Note-taking software Linux (basket)