Linking files – hard links and symlinks
A hard link is essentially an additional name for an existing file on the filesystem. Imagine you have a favorite book in your library. One day, you decide it belongs in both the Classics and Favorites sections. Instead of buying a new copy, you simply place another label on the book that leads readers from both sections to it. In the world of Linux, creating a hard link means you’re adding a new reference to the file, but it’s the same single file on the disk. If you delete the original filename, the content remains accessible through the hard link. It’s like magic: the book remains on the shelf, even if one of its labels is removed.
However, hard links have their limitations. They cannot span across different filesystems; a hard link on one drive can’t point to a file on another, and they cannot link to directories to prevent potentially creating loops within the filesystem.
Enter symlinks, which are...