First, this is a FAQ. [link|http://www.google.com/search?hl=en&lr=&ie=ISO-8859-1&q=linux+root+password+recovery|Google for it]. There's even a [link|http://www.zotteljedi.de/guides/recover-passwd-mini-HOWTO.html|unofficial Root Password Recovery mini-HOWTO], though the procedure's more complex than I'd recommend.

\r\n\r\n

If you're booting with LILO, at the boot prompt, (boot:) you'll want to enter:

\r\n\r\n
\r\n
\r\nBoot:  vmlinuz single init=/bin/bash\r\n
\r\n
\r\n\r\n

This assumes your boot kernel is vmlinuz. It usually is. If the boot sequence runs without giving you a prompt, hold down the <shift> key after system POST to get the LILO prompt. Avoid this problem in future by adding a 'timeout (tenths of seconds delay)' to your /etc/lilo.conf'. I use "timeout 200" for a 20 second delay.

\r\n\r\n

Boot. You'll have bash as your root shell, and your root partition is mounted read-only. Remount it writeable, change/set your root password, mount root read-only, and hit the reset or power switch (shutdown won't work booted in this mode):

\r\n\r\n
    \r\n
  1. mount -o remount,rw /
  2. \r\n
  3. passwd
  4. \r\n
  5. mount -o remount,ro /
  6. \r\n
  7. (Hard system restart)
  8. \r\n
\r\n\r\n

There are many other ways to do this, the above sequence is among the easier. If you're booting with GRUB, the principle's the same, though the first step is slightly different -- you'll edit your boot stanze by hitting 'e' at the GRUB screen. Other steps are the same. Other alternatives include using a boot disk, an alternate boot partition, chroot mounts, etc. Which is less to suggest complexity than flexibility.