简介:Linux的链接文件分为软链接与硬链接

理解:1.软链接可以跨分区,但源文件不可删除

          2.硬链接不可以跨分区,但可以将源文件删除  


[root@localhost ~]# cd /tmp/
[root@localhost tmp]# touch a b c
[root@localhost tmp]# ln -s a aa
[root@localhost tmp]# ln b bb
[root@localhost tmp]# ls -il
total 64
65453 -rw-r--r-- 1 root root    0 Dec 18 19:23 a
65456 lrwxrwxrwx 1 root root    1 Dec 18 19:24 aa -> a  #可以看出软链接文件是不同的inode
65454 -rw-r--r-- 2 root root    0 Dec 18 19:23 b
65454 -rw-r--r-- 2 root root    0 Dec 18 19:23 bb        #硬链接的inode相同
65455 -rw-r--r-- 1 root root    0 Dec 18 19:23 c
[root@localhost tmp]# rm a b
rm: remove regular empty file `a'? y
rm: remove regular empty file `b'? y
[root@localhost tmp]# ls -li
total 56
65456 lrwxrwxrwx 1 root root    1 Dec 18 19:24 aa -> a #此时链接文件损坏,文件闪烁
65454 -rw-r--r-- 1 root root    0 Dec 18 19:23 bb    #删除源文件b,bb文件不受影响
65455 -rw-r--r-- 1 root root    0 Dec 18 19:23 c
拓展:如何查找出相同iNode的文件呢?(提示通过find -inum)