问题
I was browsing a directory on a Linux machine, and when doing a detailed listing I noticed that a link is pointing to itself, for example:
somelink -> /path/to/directory/somelink
I am wondering what is the reason for doing such a thing?
回答1:
If the somelink
is in /path/to/directory
then this is an invalid symlink. If you try to access it, the filesystem will give you an error (probably something like too many levels of symbolic links*). It could have been a typo (or some other mistake) when it was created, or the symlink got moved somehow and ended up linking to itself.
回答2:
There's no good reason for a circular symlink. Most probably, it was created by accident.
来源:https://stackoverflow.com/questions/12680821/what-are-circular-symlinks-in-unix-like-systems-used-for