AIX系统中软硬链接理解

在AIX系统中,有两种链接文件:软连接和硬链接。他们有些什么却别呢,一下是我的个人理解,如有误之处,请大家指出。
现在系统中创建一个测试目录test,以及在目录下touch一个测试文件test.conf。
然后对test.conf文件创建一个软连接:
1、文件的硬链接是和源文件的权限、大小都是一致的,相当于源文件的别名;软链接只是相当于一个指针指向源文件。
# ln -s test.conf test1.conf
# ls -l 
total 0
-rw-r--r--    1 root     system            0 Nov 08 07:52 test.conf
lrwxrwxrwx    1 root     system            9 Nov 08 07:52 test1.conf -> test.conf
然后对test.conf文件创建一个硬链接:
# ln test.conf test2.conf
# ls -l
total 0
-rw-r--r--    2 root     system            0 Nov 08 07:52 test.conf
lrwxrwxrwx    1 root     system            9 Nov 08 07:52 test1.conf -> test.conf
-rw-r--r--    2 root     system            0 Nov 08 07:52 test2.conf
2、在修改硬链接的两个文件其中一个的权限时,另一个文件权限也一样会被修改;而软连接不会。
# ls -l
total 0
-rw-r--r--    2 root     system            0 Nov 08 08:00 test.conf
-rw-r--r--    2 root     system            0 Nov 08 08:00 test2.conf
# chmod u+x,g+w,o+w test.conf
# ls -l
total 0
-rwxrw-rw-    2 root     system            0 Nov 08 08:00 test.conf
-rwxrw-rw-    2 root     system            0 Nov 08 08:00 test2.conf
# chmod u-x,g-w,o-w test2.conf
# ls -l
total 0
-rw-r--r--    2 root     system            0 Nov 08 08:00 test.conf
-rw-r--r--    2 root     system            0 Nov 08 08:00 test2.conf
3、软连接可以在任何文件系统下创建,但是硬链接只能在本文件系统中创建。
# ln -s test.conf /test2.conf
# ls -l
total 0
-rw-r--r--    1 root     system            0 Nov 08 07:52 test.conf
lrwxrwxrwx    1 root     system            9 Nov 08 07:52 test1.conf -> test.conf
# ln test.conf /test4.conf
ln: test.conf and /test4.conf are located on different file systems.
4、在删除文件时,如果删除源文件之后,软连接不可用,但硬链接任然可以访问源文件中的数据。
#rm test.conf
#more test2.conf
more file
#more test1.conf
test.conf:A file or directory in the path name does not exist.
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值