linux 硬连接与软连接

夙愿已清 提交于 2019-11-27 01:11:15

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

转载于:https://www.cnblogs.com/nzbbody/p/4440400.html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!