码迷,mamicode.com
首页 > 系统相关 > 详细

linux 硬连接与软连接

时间:2015-04-20 00:16:31      阅读:172      评论:0      收藏:0      [点我收藏+]

标签:

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

linux 硬连接与软连接

标签:

原文地址:http://www.cnblogs.com/nzbbody/p/4440400.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!