Suse & OpenSuse : Tips, Tricks, Tutorials, How Tos and Troubleshooting

How to recover OpenSuse Lost Root Password

Hopefully not but from time to time, we may somehow forgot what our root password is.  This can happen in the case where you are managing a teaching laboratory, CAD/CAM workstations or your grandmother’s OpenSuSE PC!  These are situations where once the machine is setup, you rarely need to have system administration access.  So, the first answer is … re-install!

Heck no, an easier way is to

  1. Boot into single user mode
  2. Change password
  3. Reboot

Booting into single user mode

Assuming that you did not password protect  your GRUB boot loader (default boot loader for most Linux distribution), to boot into single user mode in most Linux distribution, you simply need to ask it to boot into single user mode (runlevel 1) but as rightly pointed out (see comment), in OpenSuSE, instead of simply pressing “1” when greeted with the following screen, you need to instead input “init=/bin/sh“. By pressing “1″, you will still be required to enter the root password.

GRUB startup

GRUB startup

(Note, not all GRUB screens are like that, if by pressing “1”, it boots immediately, then the next time, press ESC to go to the text based menu.  From there, select the entry and press “e” to edit and then go to the boot instruction line and press “e” again.  You can then add the “1” at the end of the command.  Press “b” after that to boot)

Change password

Once in single user mode, you should just get the following command line prompt.

your-hostname:~ #

You are actually logged in as root (superuser) and you can change the password from there.

your-hostname:~ # passwd
Changing password for root.
New Password:

Enter your new password (and this time remember it!).  You should see the following to confirmed that the password has changed.

Reenter New Password:
Password changed.

Reboot

Simlpy type,

your-hostname:~ # reboot

Your root password has been reset!

RSS feed | Trackback URI

5 Comments »

Comment by cyberorg
2009-02-28 07:43:44

It does not work like that on SUSE :)

Try it out and see it booting in runlevel 1 work without giving root password.

try “init=/bin/bash” in place of “1″

 
2009-04-05 23:16:47

[...] earlier posting was for OpenSuSE, but for SuSE, the security is even tighter.  The following technique would [...]

 
Comment by Antani
2009-04-09 06:55:12

It worked on SLES 10 like a charm!
only put 1 at boot :D :D :D

 
Comment by susefan
2011-05-29 21:48:32

None of this works for opensuse 11.3 when the system enters single user mode, you can not type anything the message is cennot set terminal process group (-1). No Job Control in this shell.

 
 
Name (required)
E-mail (required - never shown publicly)
URI
Your Comment (smaller size | larger size)
You may use <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> in your comment.