HARD AND SYMBOLIC LINKS:
Before starting, we must clarify that ALL files and directories in Linux have an INODE, which is a unique identifier for each of these and that has information about each of these such as size, permissions, and among others, well the links below will make use of the INODEs in a different way.
SYMBOLIC LINK:
It is also known as a soft link, to understand this connection we can give an example of window shortcuts, that is, symbolic links have a folder or ORIGINAL FILE that is located somewhere on the disk and in turn have A LINK on which it can be in any folder but will always point to the original file, it must be taken into account that it can also have several links, that is, several symbolic links of the same ORIGINAL FILE.
A modification made using this link will be reflected in the original file, but if the link is removed, the authentic link will not be removed as the INODE of the original file is not affected by these same symbolic links.
HARD LINK:
Hard links, unlike soft links, are linked to the same INODE, which means that everything that happens to the other file with the same INODE will be mirrored. It is also necessary to specify that these links copy all the characteristics that the other files have for the INODE (permissions, content, size, ...).
Hard links cannot be created with directories and not outside the file system itself, while a soft link can.
HOW TO CREATE SYMBOLIC LIKNS:
We need the ln command for create a link and the -s option for create a Symbolic link, in this may:
ln -s <existing _file> <file_name>
IMPORTANT: If you move or delete the original file, the links will generate an error.
HOW TO CREATE HARD LINKS:
For create Hard links we use ln command and use -v option for verbose mode. Please remebner that de file must be in the filsystem. We can create in this way:
ln -v <existing _file> <file_name>
DIFFERENCE BETWEEN THEM:
- Source files do not share their INODE with symbolic links while hard links do share it with their source file.
- When you delete a symbolic link, do not delete the original file, otherwise it happens with hard files, which if one is deleted, the others files are deleted except for the original file.
- Symbolic lnks allow creating files and directories while hard links cannot create directories.
EXAMPLES:
For this example I go to create a file1 for make a Symbolic link and file2 for create a hard link.
Now I go to create a Symbolic link with file1 file and the command ln -s , in this way:
Keep in mind that when listing with ls -li , we realize that its INODE is different.






