为什么ln不显示../..?

时间:2017-01-12 06:15:52

标签: linux bash

$ mkdir testln && cd testln
$ echo 123 > source
$ mkdir -p aa/bb/cc/dd
$ ln -s source aa/bb/cc/dd/dest
$ ll aa/bb/cc/dd/
total 8
lrwxr-xr-x  1 sato sato 6  1 12 15:08 dest -> source
$ cat aa/bb/cc/dd/dest
cat: aa/bb/cc/dd/dest: No such file or directory
$ cd aa/bb/cc/dd/
$ ll
total 8
lrwxr-xr-x  1 sato sato 6  1 12 15:08 dest -> source
$ ln -s ../../../../source dest2
$ ll
total 16
lrwxr-xr-x  1 sato sato  6  1 12 15:08 dest -> source
lrwxr-xr-x  1 sato sato 18  1 12 15:10 dest2 -> ../../../../source

如您所见,我做了两个ln

第一个只显示dest -> source而不是dest -> ../../../../source,并显示No such file or directory,为什么会这样?

1 个答案:

答案 0 :(得分:0)

应该是:

ln -s ../../../../source aa/bb/cc/dd/dest

source路径必须相对于dest。查看man ln