我对 unix/inode 文件系统的理解是,两个名称可以引用相同的 inode 编号,但在这种情况下,引用计数将为 2。但是,我今天注意到/etc/hosts 文件和/private/etc/hosts文件都引用了同一个inode号,但是引用计数都是1,为什么引用计数不是2,说明两个路径引用的是同一个inode?p>
% ls -li /etc/hosts
38402042 -rw-r--r-- 1 root wheel 236 May 14 23:13 /etc/hosts
% ls -li /private/etc/hosts
38402042 -rw-r--r-- 1 root wheel 236 May 14 23:13 /private/etc/hosts
最佳答案
硬链接(hard link)共享同一个inode,硬链接(hard link)更像是一个镜像副本。
硬链接(hard link)语法:ln file1 file2
如果您删除了 file1,它仍然是 file2。
https://stackoverflow.com/questions/23671083/