linux 硬连接与软连接

1、linux中文件占用一个inode,inode指向文件内容。
2、文件名可以认为是一个指针,指向inode。硬连接相当于指针的整体拷贝,并不是对文件内容的拷贝。两个文件名(两个指针)都能修改文件,删除一个不影响另外一个,如下:
[root@localhost home]# touch aaa
[root@localhost home]# cat >aaa
hello
[root@localhost home]# ln aaa aaa.hl
[root@localhost home]# cat >>aaa.hl
world
[root@localhost home]# more aaa
hello
world
[root@localhost home]# rm -f aaa
[root@localhost home]# more aaa.hl
hello
world
3、软连接相当于指针的引用,删除指针,引用也就无效了。
[root@localhost home]# touch aaa
[root@localhost home]# cat >aaa
hello
[root@localhost home]# ln -s aaa aaa.sl
[root@localhost home]# cat >>aaa.sl
world
[root@localhost home]# more aaa
hello
world
[root@localhost home]# rm -f aaa
[root@localhost home]# more aaa.sl
aaa.sl: No such file or directory

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。