Creating symbolic links without "too many levels of symbolic links" error
Lets create a shell script named 'what' with a single line, no! two lines with shebang included.1: #!/bin/bash
2: echo "nothing!"
and save the file.
Now, make it executable.
$ chmod +x what
then create a symbolic link for it in bin or any other directory that is in your PATH variable.
[
to check the path just echo it,
$ echo $PATH
]
$ ln -s /home/user/what /bin/what
here, you could notice that the absolute path of the file to be symlinked is used with 'ln'. It would be sometimes tempting to use relative path or you might feel lazy to type in full path. Nevertheless, always use absolute path while symlinking. If done with relative path, here for example. While doing,
$ ln -s what /bin/what
then, 'what' would be symlinked to /bin/what. i,e I can now run 'what' script from anywhere in my system just like we use 'cd', 'ls' and so. Now when I try to execute 'what', the symlink (/bin/what ) will again point to 'what' (the command) and again it will go run the symlink /bin/what and again from symlink it will point to command 'what' and the cycle continues. This will be indicated as error message in shell as,
zsh: too many levels of symbolic links: what