硬链接:
硬链接充当所选文件的副本(镜像)。它访问原始文件中可用的数据。
如果先前选择的文件被删除,文件的硬链接仍将包含该文件的数据。
软链接:
软链接(也称为符号链接)充当文件名的指针或引用。它不访问原始文件中可用的数据。如果先前的文件被删除,软链接将指向一个不再存在的文件。
下面列出了两者之间的一些显着差异:
Comparison Parameters | Hard link | Soft link |
---|---|---|
Inode number* | Files that are hard linked take the same inode number. |
Files that are soft linked take a different inode number. |
Directories | Hard links are not allowed for directories. (Only a superuser* can do it) |
Soft links can be used for linking directories. |
File system | It cannot be used across file systems. |
It can be used across file systems. |
Data | Data present in the original file will still be available in the hard links. |
Soft links only point to the file name, it does not retain data of the file. |
Original file’s deletion | If the original file is removed, the link will still work as it accesses the data the original was having access to. |
If the original file is removed, the link will not work as it doesn’t access the original file’s data. |
Speed | Hard links are comparatively faster. | Soft links are comparatively slower. |
笔记:
- 索引节点号 – 索引节点号是分配给 Linux/Unix 系统中所有文件的唯一编号。
- 超级用户 – 与普通用户相比,超级用户拥有更多的权限。他们可以更改文件所有权并设置权限。
图示: