Symbolic Links
These links (symlinks) are the easiest of the two forms to understand. It's the same as a Windows shortcut. Essentially it's an alias to an actual file, but it contains no actual information about that file it just points to the file on the disk. Behind the scenes, when a symlink is created, it actually creates a separate inode on the disk which points to the actual inode of the target file.
- If you delete the symlink, the file it points to (target) is NOT deleted.
- If you move the target file to somewhere else, the symlink will not work.
- If you delete the target file, the symlink will not work.
- Symlinks will point to any file or directory, regardless on what volume the target resides.
Hard Links
This is the default type of link in Linux. Although superficially it looks the same as a symlink, in that an alias is created that points to the target file, behind the scenes it points directly to the inode of the target file on disk. Due to this direct linking, it means the exact number of hard links to the target file can be calculated.
The command that is used for creating Links is ln. The format is;
ln [OPTION] TARGET LINK_NAME
For creating a Symbolic Link;
ln -s /usr/bin/vim vimmy
For creating a Hard Link;
ln /usr/bin/vim vimmy
No comments:
Post a Comment