/errors/coreutils/too-many-levels-of-symbolic-links
Too many levels of symbolic links
verified onenvironmentlocal · linux 6.18.44-fc-v140 x64 · GNU bash 5.2.21 · ls (GNU coreutils) 9.4updated
- tool
- GNU coreutils
- exit code
- 1
- versions
- GNU coreutils 8.x, GNU coreutils 9.x
- os
- linux, macos
Too many levels of symbolic links is the text of the ELOOP error. The kernel follows a limited number of symbolic links while resolving one path, and gives up when a link points back to itself or when the chain is too long. The fix is to find the cycle and replace one of its links.
Reproduce it
ln -s b a
ln -s a b
cat aOutput · exit 1
cat: a: Too many levels of symbolic links
a points to b and b points to a, so the path never resolves to a file.
Find the cycle
ln -s b a
ln -s a b
readlink a
readlink b
readlink -e a || echo "no target"Output
b a no target
readlink without options prints one link target per call and does not follow the chain, so it works on a loop. readlink -e follows the whole chain and fails when it cannot resolve it.
Fix it
echo data > real.txt
ln -s real.txt a
cat aOutput
data
Sources
Related pages
errors · coreutilsrm: cannot remove 'dir': Is a directoryrm refuses to delete a directory unless you pass -r. Use rmdir for an empty directory, or rm -r for a directory and its contents after checking what it holds.errors · coreutilsmkdir: cannot create directory 'dir': File existsmkdir fails with File exists when the path is already there, as a directory or a file. Use mkdir -p to accept an existing directory, or rename the file.errors · bashbash: ./script.sh: Permission deniedbash prints Permission denied (exit 126) when a script has no execute bit or sits on a noexec mount. Run chmod +x script.sh, or start it with bash script.sh.