ln -s 软链接产生Too many levels of symbolic links错误

今天在做软连接的时候碰到一个问题:报错内容:Too many levels of symbolic links。

操作步骤如下:

[root@test ~]# ln -s pytest /tmp/

[root@test ~]# cd /tmp/

[root@test tmp]# cd pytest

-bash: cd: pytest: Too many levels of symbolic links
查找一番发现建立软链接时采用的是相对路径,所以才会产生这样的错误,解决方式是:采用绝对路径建立软链接
[root@test tmp]# rm -f pytest

[root@test tmp]# cd

[root@test ~]# cd -

/tmp

[root@test tmp]# ln -s /root/pytest /tmp/

[root@test tmp]# cd pytest/