By mistake, I executed these commands :
sudo ln -sf bash /bin/sh
sudo ln -sf bash /bin/bash
When I rebooted the Linux server in recovery mode I got this message:
init : Failed to spawn friendly-recovry pre-start process: unable to execute: Too many levels of symbolic links
And Linux doesn't run.
any help is greatly appreciated
Best Answer
I think you somehow ended up with
When the system is first trying to run a shell, it will go into a loop resolving
bash
, which is, according to the symlink,the same as
bash
, which is the same asbash
, which is the same asbash
, which is the same asbash
... until memory allowed for this runs out.To fix the problem, we need to know what
/bin/sh
was before, normally it points tobash
or todash
. Which Linux distribution do you use?There are other shells installed normally, like
dash
, orzsh
, but as the system looks forsh
when starting, I see no way to make use of these without external help.I think you will need to boot a live system from a CD, or connect the harddisk to another computer;
And from there, mount the root disk, and fix the link.
If the shell was really deleted by the "force" in
ls -sf
, you need to get the shell binary from somewhere.Could also work to link
/bin/sh
to a similar shell, not the one it was pointing to - (but that seems to be what you were doing last.)The
could have deleted
/bin/bash
- but when I try something similar, I get an error:Are you sure about the commands? In which directory did you run them?