Chinaunix首页 | 论坛 | 博客
  • 博客访问: 72234
  • 博文数量: 22
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 134
  • 用 户 组: 普通用户
  • 注册时间: 2015-04-27 22:31
个人简介

梦想是要有的,万一实现了呢!

文章分类

全部博文(22)

文章存档

2015年(22)

分类: 服务器与存储

2015-05-09 08:58:24

创建软连接时。源文件没有使用绝对路径造成的问题:
一、
[root@hitwh_Gypsy tmp]# ls *.txt
1.txt
[root@hitwh_Gypsy tmp]# cd
[root@hitwh_Gypsy ~]# ls *.txt
3.txt  vimTest.txt
[root@hitwh_Gypsy ~]# touch 1.txt
[root@hitwh_Gypsy ~]# echo "/root/1.txt" > 1.txt
[root@hitwh_Gypsy ~]# cat 1.txt
/root/1.txt
[root@hitwh_Gypsy ~]# ln -s 1.txt /tmp/2.txt
[root@hitwh_Gypsy ~]# ls -l /tmp/2.txt
lrwxrwxrwx 1 root root 5 12月  8 20:23 /tmp/2.txt -> 1.txt
[root@hitwh_Gypsy ~]# cat /tmp/2.txt
tmp 1.txt
[root@hitwh_Gypsy ~]# cat /tmp/1.txt
tmp 1.txt
[root@hitwh_Gypsy ~]# cat ./1.txt
/root/1.txt

ln -s 1.txt /tmp/2.txt
由于  /root/ 和 /tmp/ 目录下都有 1.txt  ,本意是将 /root/1.txt  链接到 /tmp/2.txt
但是系统将 /tmp/1.txt 是为了源文件,造成连接错误



二、
[root@Gypsy_111 dir2]# ln -s 0.txt ../dir1/0.txt.bak
[root@Gypsy_111 dir2]# cat 0.txt
/tmp/test/dir1/0.txt
[root@Gypsy_111 dir2]# cat ../dir1/0.txt.bak
cat: ../dir1/0.txt.bak: 没有那个文件或目录                                   
[root@Gypsy_111 dir2]# ll ../dir1/0.txt.bak
lrwxrwxrwx 1 root root 5 5月   9 08:36 ../dir1/0.txt.bak -> 0.txt
[root@Gypsy_111 dir2]# ln -s /tmp/test/dir2/0.txt ../dir1/0.txt.bak
ln: 创建符号链接 "../dir1/0.txt.bak": 文件已存在
[root@Gypsy_111 dir2]# ln -s /tmp/test/dir2/0.txt ../dir1/00.txt.bak
[root@Gypsy_111 dir2]# cat 0.txt
/tmp/test/dir1/0.txt
[root@Gypsy_111 dir2]# cat ../dir1/00.txt.bak
/tmp/test/dir1/0.txt
[root@Gypsy_111 dir2]#
[root@Gypsy_111 dir2]# cd -
/tmp/test/dir1
[root@Gypsy_111 dir1]# ls
00.txt.bak  0.txt.bak  1.txt
[root@Gypsy_111 dir1]# ll
总用量 4
lrwxrwxrwx 1 root root 20 5月   9 08:38 00.txt.bak -> /tmp/test/dir2/0.txt
lrwxrwxrwx 1 root root  5 5月   9 08:36 0.txt.bak -> 0.txt
-rw-r--r-- 1 root root 33 5月   9 08:27 1.txt
[root@Gypsy_111 dir1]# vim 0.txt
[root@Gypsy_111 dir1]# ll
总用量 8
lrwxrwxrwx 1 root root 20 5月   9 08:38 00.txt.bak -> /tmp/test/dir2/0.txt
-rw-r--r-- 1 root root  6 5月   9 08:40 0.txt
lrwxrwxrwx 1 root root  5 5月   9 08:36 0.txt.bak -> 0.txt
-rw-r--r-- 1 root root 33 5月   9 08:27 1.txt
[root@Gypsy_111 dir1]# cat 0
00.txt.bak  0.txt       0.txt.bak
[root@Gypsy_111 dir1]# cat 0.txt.bak
asasa
[root@Gypsy_111 dir1]#


这个实验进一步证明了之前的推论。

关于硬链接
如何根据 inode 号 查找相应文件?

阅读(971) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~