In one of my earlier posts, we discuss about password protecting single user mode which can enhance the security of your system. But there is also a different aspect of this security patching that if you forgetĀ  the root password, you can’t even login to single user mode to change the password or to perform any other maintenance related task. So today we’ll deal with this critical situation where you can change your password even if your single user mode is password protected.

The process is quite simple. At the time of booting press any key to edit the grub menu. Select the operating system and press e. Now go to the kernel line and press e again. It’s time to change some kernel parameters. So write init=/bin/bash and press enter to come out of this. Now press b to boot.So what we have actually done is to tell kernel that instead of starting normal inittab file just give me a simple bash shell.Now you’ll get a bash shell.
hacking password protected single user mode in Linux The process from this point of time is as following where we need to issue some commands-

  • First of mount the / partition in read-write mode. So issue mount -o remount, rw / command.
  • Now change the password using passwd command.
  • Again remount the / partition in read only mode by using mount -o remount, ro / command.

Now just restart the machine and you’ve successfully changed your root account password. I think that you’ll love this small hack. Enjoy!!!