Last updated
Last updated
Commonly referred to as symbolic links, soft links link together non-regular and regular files. They can also span multiple filesystems. By definition, a soft link is not a standard file, but a special file that points to an existing file. Let's look at how to create a soft link. I use the ln -s
command and the following syntax:
ln -s /etc/grub2.cfg grub2.cfg
If the original file is deleted, the soft link is broken. This situation is referred to as a dangling soft link. If you were to create a new file with the same name as the original, your dangling soft link is no longer dangling at all. It points to the new file created, whether this was your intention or not, so be sure to keep this in mind.
Unlike soft links, When changes are made to the original file, the other reflects those changes. The permissions, link count, ownership, timestamps, and file content are the exact same. If the original file is deleted, the data still exists under the secondary hard link. The data is only removed from your drive when all links to the data have been removed. If you find two files with identical properties but are unsure if they are hard-linked, use the ls -i
command to view the inode number. Files that are hard-linked together share the same inode number.
lets create a hard link :
ln /etc/hosts /tmp/hlhosts -> creating a hard link to /etc/hosts under /tmp.
After understanding the difference between hard and soft links, lets move on to the next chapter, common text tools and grepping.
Learn the different types of links and how to create one.