Unlock root

Howto unlock the root account of any linux system without DVD or ISO file.

Use cases:

  • root password is lost or unknown
  • /etc/sudoers is corrupt

WARNING: The machine must be reset or rebooted.

Recipe:

  • Connect to the linux console
  • Force a reboot of your machine
  • Wait for the GRUB bootmenu and press “e”
  • Find the line where the kernel is loaded and add
init=/bin/bash

Next: Press CTRL-X (for germans: STRG-X)

The system starts and opens a bash without the need to enter a password.

  • optional step: load your keyboard with “loadkeys de” (example for german language)
  • mount the root filesystem in read-write mode with:
export PATH=$PATH:/sbin
mount -o remount,rw /

Now: Do your repairs!

  • edit sudoers with “visudo”
  • or set a new password for root with “passwd root”

Finally: reboot the system

mount -o remount,ro /
echo 1 > /proc/sys/kernel/sysrq
echo b > /proc/sysrq-trigger