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

posted on 2015-04-19 23:24  Andy Niu  阅读(170)  评论(0编辑  收藏  举报