RTFM for the series, reported below are the instructions given in Italian official documentation on Debian to recover the root password. I do it for the consumption of a very lazy person who asked me.

8.1.1 "I forgot the root password!" (1)

And 'possible to boot the system and access to the root account, even if you do not know your password, simply having access to the keyboard. (This assumes there are no password requests from the BIOS or the boot loader such as lilo that would prevent access to the system).

This procedure requires no external boot disks and no change in BIOS. In this context, "Linux" is the label for booting the kernel in a Debian install.

At the lilo boot screen, as soon as boot: appears (in some systems, you must press the shift key to prevent automatic booting) and when lilo uses the framebuffer you press TAB to see the options you type), enter:

boot: Linux init=/bin/sh

The system boots the kernel and run / bin / sh instead of its standard init. At this point you have gained root privileges and a root shell. Since / is mounted read-only and many disk partitions have not been mounted yet, you must do the following to have a reasonably functioning system.

init-2.03# mount -n -o remount,rw /
init-2.03# mount -avt nonfs,noproc,nosmbfs
init-2.03# cd /etc
init-2.03# vi passwd
init-2.03# vi shadow

(If the second data field within the / etc / passwd is "x" for every username, your system uses shadow passwords, you must edit / etc / shadow.) To disable the root password, edit the second field in the password file so that it is empty. Now you can reboot and log in as root without a password. When booting into runlevel 1, Debian (at least after Potato) requires a password, which some older distributions did not.

It 's good to have a minimal editor in / bin if / usr is not accessible (see Rescue editors, Section 11.2).

Also consider installing the sash package. If the system becomes unbootable, execute:

boot: Linux init=/bin/sash

sash serves as an interactive substitute for sh even when / bin / sh is unusable. It's statically linked, and includes many standard utilities as built-ins (type "help" at the prompt for a reference list).

8.1.2 "I forgot the root password!" (2)

Boot from any emergency boot disk set / root. If, for example, / dev/hda3 is the original root partition, the following will let one edit the password file as easily as above.

# mkdir fixit
# mount /dev/hda3 fixit
# cd fixit/etc
# vi shadow
# vi passwd

The advantage of this approach over the previous method is that it requires knowledge of the lilo password (if any). However, one must be able to set the BIOS, if not already, so the system to boot from floppy or CD.

Source: http://www.debian.org/doc/manuals/reference/ch-tips.it.html

Share this content:
  • del.icio.us
  • Google Bookmarks
  • Digg
  • Facebook
  • Technorati
  • MySpace
  • Twitter