when you lose your Linux root password? Since root = god in Linux-land
all is lost, right? Actually, no. You'll never recover a lost root
password, but you can reset it.
First off, try booting into what's known as single-user mode. How you
do so depends on your boot manager.
Select the Linux system you want to
boot from the graphical menu and press e. You'll find
yourself in a
mini editor where you can alter boot commands.
Move the cursor to the end
of the boot
command line, add a space
and then either a 1
or the word single.
Then hit Enter
to boot this line.
Press any key but
at the boot
menu. If that takes you to a command prompt, type linux single,
and let the system boot.
Once the system's running,
yourself in runlevel 1 (aka. 'single-user mode').
From here it's just a matter of typing passwd to
change the root
password followed by exit
to reboot into the usual runlevel.
But what if the boot process is
protected from this sort of interference? Many modern Linuxes like
Suse and Mandrake won't let you start runlevel 1 unless you first
supply the root password. Oh, oh; Catch 22! You need the password
you've forgotten in order to get into the system to reset the
password. What now?
the system in another version of
You'll need bootable Linux disk.
Virtually everyone these days produces versions of Linux that boot
and run from CD (they're typically called 'live' distributions) but
my personal favourite it Tom's
Root and Boot
(tomsrtbt), a complete
Linux system on a floppy disk.
Boot into your alternate
either from CD or floppy. If you booted into a graphical system start
a console session.
- Make a temporary directory: mkdir
- Mount the root disk: mount /dev/hda5
- Edit and save the shadow password
tmp/mylinux/etc/shadow. (Check this link
if you need help with
the vi editor's confusing commands.)
The basic idea here is to
encrypted password. Here's how it'll look in /etc/shadow...
You want to remove the
so it looks like this...
Go back to where you were: cd /
Unmount the temporary directory: umount
Reboot the system: shutdown
Root's password is now
blank. (Just hit
when prompted for it.) Be sure to reset it though. Blank
passwords aren't terribly secure!