Please note that this blog has been moved.
Now it has its own domain: mynixworld.info 🙂
If you want to read the latest version of this article (recommended) please click here and I open the page for you.
For those who don’t share the passion for Linux the title of this post might be rather odd. ‘root‘ is the name of Linux super/administration user.
If you gain the control of this user then you rule the system. If you accidentally lose the control of this user then … should I mention that you cannot administrate your system anymore?
Well, that’s not entirely correct or, with other words, that depends.
I have to share an odd story which may be useful for others. I just installed a Gentoo distro on one of my systems and I thought that it will be a good idea to lock the root login such no one can ever use that name to connect the system. Instead one could login with his own user-name and later use the sudo program.
To lock the root login all you have to do is to use the passwd tool:
passwd -l LOGIN #where LOGIN could be root, etc
After that you cannot login anymore to the system using the root login. All you can do, as said earlier, is to login to system using your user and later to call sudo program like this:
which in turn will ask your password and only then you can run that command or whatever.
What’s happening when you have already locked your root login and then you just discovered that your system does not have sudo program pre-installed? Well, not much. In fact, you cannot administrate your system anymore:
- cannot (un)install programs
- cannot run programs which requires root privileges
- probably you will not even have sufficient permission to turn-off/reboot your system
Grab a rescue disk, boot the system from the rescue disk, mount the root partition of your system, edit the /etc/passwd and /etc/group files such you become a root-alike user.
The /etc/passwd file contains, among others, the definition of your login:
1000: 1000::/home/eugen:/bin/bash ...
These 1000 is the UID(User ID) and GID (Group ID) and to become root you should replace it with zero (because zero is the UID/GID of root login):
... eugen:x:0:0::/home/eugen:/bin/bash ...
I’m not quite sure that it’s necessary a similar operation in /etc/group but in case this isn’t sufficient you might change the /etc/group as well:
... eugen:x:0: ...
After rebooting your system your user have root privileges so it can do anything, even unlock the root login, install sudo and whatever is necessary such that this story never happens again.
Btw: after everything comes back to life don’t forget to restore the original UID/GID of your user in /etc/passwd and/or /etc/group files.