Hard link & Soft link
Hard link
- Creates another name that points to the same file.
- Even if the original file is deleted, you can still access the file through the hard link.
- Can only be created within the same file system.
- Reflected in the link count of the
i-node.
Hard link example
1ln original.txt hardlink.txt
After executing the command above, original.txt and hardlink.txt will
share the same i-node and point to the same file.
Soft link (Symbolic link)
- Creates an alias that points to the path of the original file.
- It is a separate file (link) from the original file and does not share an i-node.
- If the original file is deleted, the soft link will break (Broken link).
- Can be created not only within the same file system but also across different file systems.
Soft link example
1ln -s original.txt softlink.txt
In this case, softlink.txt becomes a symbolic link that refers to the
path of original.txt.