如果按这种方式创造链接:
$ tree --noreport -fp
.
└── [drwxr-xr-x] ./topdir
├── [drwxr-xr-x] ./topdir/source
└── [drwxr-xr-x] ./topdir/outputdir
$ cd /topdir
$ ln -s source outputdir
$ tree --noreport -fp
.
├── [drwxr-xr-x] ./source
└── [drwxr-xr-x] ./outputdir
└── [lrwxrwxrwx] ./outputdir/source -> source
创造的链接将是错误的,因为source是在outputdir里取查找的
source指向/topdir/outputdir/source而不是/topdir/source.
解决:
1. 使用绝对路径:
ln -s "$(pwd)/source" outputdir
2. 使用相对路径:
cd /topdir
ln -s ../source outputdir
参考链接: https://www.baeldung.com/linux/too-many-levels-of-symlinks