Let's say I've gone and done a silly thing, such as using 'chsh' to change the root user's shell to a bad file path. Future logins to the root account will abruptly fail, citing /bin/whatever not being found, and boot you back out to the login screen. Barring a recovery mode or inserting a LiveCD to edit /etc/passwd, what are my options for getting my system back? Let's also assume (for fun?) that there are no other users in wheel. Thoughts?
|
|
When booting, append One additional variation of this method might be necessary on some systems loaded in two-stage mode (with an initrd image). If you notice that the boot options contain * This is because in that environment, the shell is seen by the kernel as the init program - which is the only process that kernel knows - it represents a running system underneath to the kernel's eye. Suddenly ending that process, without telling the kernel to shutdown the system, must result in kernel panic. (Wouldn't you panic if suddenly everything around you went black and silent?) |
|||||||||||||||
|
|
You could use
Otherwise you could do something similar if your ssh daemon allows login to root:
You could also set a shell as your init in your bootloader, for example, |
|||||
|
|
If your bootloader is configured to allow live editing of the kernel parameters, a solution is to reboot and use a shell as init process, e.g. |
||||
|
|
If the gist of your question is that you've locked out all the ways to become root, then by definition you cannot become root. It is common to allow three ways to become root on a unix system:
A traditional way to protect against root's shell being unavailable is to define another account with UID 0 and a different shell ( |
|||
|
|
|
The above answers are great and I learned from reading them. If you don't remember the details of these approaches and don't mind rebooting, you can always boot your system using a live CD distro, mount the / partition and then edit /etc/passwd and reboot. Not as elegant as the above solutions, but easier to remember. |
|||
|