Navrangpura, Ahmedabad, Gujarat
Follow us :

What is Hard Link & Soft Link …?

If the link’s source—the item it points to—is moved or deleted, these links will act differently. Hard links always point to the source, even when they are relocated or deleted, whereas symbolic links are not changed and only include a string that is the path name of their target.

Take a.txt file, for instance. It is still possible to access a file via a hard link even if we make one and subsequently erase it. A soft link gets dangling and we are unable to access the file if we make one and then remove the original file. In general, a soft link functions as a shortcut, whereas a hard link adds references to a location (like in Windows)

Soft links, also known as symbolic links, and hard links are the two different kinds of links in Linux. Although references to files or directories can be made using any form of link, there are some significant distinctions between them.

1 Hard Link:  

  • The target and the hard link need to be on the same filesystem.
  • In essence, hard links refer to the identical disk data blocks
  • A hard link is an extra pointer to the destination file’s inode or data structure on disk.
  • Without the -s option, they are formed with the ln command.
  • As long as there is at least one hard link pointing to the original file, the data will not be released upon its deletion.

An illustration of a hard link:

ln highsky.txt hardlink.txt

The link count in the ls -l output can be used to identify hard links. All hard links going to the same inode are included in a file’s link count.

In conclusion, hard links are extra references to the same inode that need to be on the same filesystem, whereas soft links are references to files by name that can span other filesystems. Hard links stay connected to the data as long as there is at least one link to the inode, whereas soft links can break if the target is changed or removed. e.

2 Soft Link:

  • The soft link breaks or hangs if the destination file or directory is moved or removed.
  • With the ln -s command, they are generated.
  • It is shown as a different file with the target’s path in it.
  • The destination file or directory is essentially referenced or shortcut by a soft link.
  • Soft links are capable of spanning several filesystems.

An illustration of a soft link:

ln -s highsky.txt soflink.txt

The ls -l command can be used to determine whether a link is symbolic; a symbolic link will have a ‘l’ at the start of the permissions field.

Author

by admin

Leave a Reply

Your email address will not be published.

bg

Subscribe to our Newslatter

Sign Up to Our Newsletter to Get Latest Updates & Services

mail box
logo-footer
HighSky IT Solutions Pvt. Ltd. is a leading IT training and certification programs in Red hat, RSCSA Cloud, Open-source, AWS, Devops and various domains.
Contact Info

2nd floor, Rohera Arcade, opp SOTC office, Near Navrangpura police station, Navrangpura, Ahmedabad -380009 Gujarat

Copyright ©2024 Design & Developed by HighSky IT