If you want to take full advantage of the ln command, you’ll need to know the difference between soft and hard links. Soft links are cross references that point to a file or directory. If you move or delete the original file, there is no longer a target and the link leads to nothing. On the other hand, if you delete the link, the original final link remains intact. Soft links are also called symbolic links or symlinks. Soft links can be created in the Linux terminal and in the graphical user interface in the Linux file manager. You can spot a soft link in Linux by the arrow symbol on the file icon.
Hard links can only be created using the command line. They’re more extensively integrated into the memory management of an operating system and the file system being used. A hard link is a mirror copy of the original file, which has its own directory entry. Several hard links can point to the same file. In fact, Linux doesn’t distinguish technically or operationally between the original and a hard link generated later, meaning that all directory entries are treated the same and work independently of one another.
Let’s take a look at a concrete example. Say there is a video file that is only accessible in the directory ‘My Videos’. After creating a hard link, it can also be retrieved from another directory, e.g. ‘My Videos Backup’. If the original file is deleted from ‘My Videos’, it is still perfectly accessible via the hard link path to the file in ‘My Videos Backup’. This is an advantage of hard links - the additional entry in memory management doesn’t use any extra memory. It simply serves as an alternative option for access (via file path) and is not a second physical copy of the file.
Hard links are closely connected with special internal bookkeeping in Linux. Every hard link refers to an inode and is assigned a unique inode number, which is the same one assigned to the original file. A file isn’t really deleted from the inode system (and thus the entire system) until all entries (i.e. all references to the file) are made invalid by delete operations and an internal link counter is set to zero. On the other hand, if only one address entry among many is deleted or if the original file is moved into another directory, nothing changes. The remaining options for accessing the original file, which are stored in inode, are still valid.