Search This Blog

Wednesday, June 10, 2009

Superuser password Lost ?? & Single user not working ??

If "single user" mode doesn't let you in, then
  • Boot a "live distro" CD, like Ubuntu
  • Obtain a commandline (run xterm or terminal or something)
  • Get root; with "live boot" distros, this is usually dead simple, as the root password is usually provided as part of the documentation
  • Mount your real root directory onto an unused directory of the live boot environment (i.e. onto /mnt). Make certain you mount it rw
  • cd to your newly-mounted root directory
  • Enter the following command: "chroot . /bin/bash" to obtain a command prompt that uses your newly-mounted root directory and /it's/ files (including it's etc/passwd and etc/shadow)
  • Enter the passwd command to change roots password. When you are done
  • Enter "exit" to quit the chroot shell
  • cd to the real /
  • Umount your installation's root directory
  • Shutdown and Reboot
What this does is permit the password program from /your/ installation to work on the password files from /your/ installation, by running everything in an environment that starts with your installation as the root filesystem. Up to the point where you chroot, you are just establishing a running environment, but when you chroot, you have effectively re-established /your/ installation, with access as root.

No comments: