Reset root password (linux case)

Linux specific questions/information are gathered here. The main thrust of topics are applied to Centos/RedHat(RH)/Debian/Ubuntu/Gentoo distributives

Reset root password (linux case)

Postby lik » Wed Jan 05, 2011 2:47 pm

The first thing to try is to boot into single user mode. This may not work, because your system might be configured to still ask for a root password to get to single user mode.
If that's the case, use another trick that replaces init with /bin/bash.

First, try single user. If you don't see either a LILO or GRUB boot screen, try hitting CTRL-X to get one (also ESC key can be used).

If it's LILO, just type "linux single" and that should do it (assuming that "linux" is the lilo label).
If GRUB, hit 'e', then select the "kernel" line, hit "e" again, and add " single" (or just " 1") to the end of the line. Press ENTER, and then "b" to boot.

You should get a fairly normal looking boot sequence except that it terminates a little early at a bash prompt. If you get a "Give root password for system maintenance", this isn't going to work, so see the "init" version below.

Another trick is to add "init=/bin/bash" (LILO "linux init=/bin/bash" or add it to the Grub "kernel" line). This will dump you to a bash prompt much earlier than single user mode, and a lot less has been initialized, mounted, etc.

Finally, you can boot your server from your favorite live/boot cd and use 'chroot' technique to reset the password.
lik
Founder
Founder
 
Posts: 497
Joined: Wed Dec 15, 2010 3:21 am

Gentoo single user mode

Postby lik » Thu Apr 07, 2011 5:56 am

Quick note about Gentoo:

'single' doesn't work
People familiar with other distributions may be a bit confused when they try to access single user mode.

Traditionally, you append 'single' or 'S' to the end of the kernel line in GRUB or LILO. However, Gentoo now uses a different method of selecting runlevel, so if you just append 'single' you'll find yourself booting up to the default runlevel anyway.

While 'single' doesn't work like on other systems, you can specify the runlevel on just about any linux system, so appending '1' will work on Gentoo. Instead of '1' (specifying runlevel 1), you can also use 'softlevel=single'. Softlevel is a Gentoo specific option.

There is a slight difference between '1' and 'softlevel=single'. While '1' halts at runlevel 1, 'softlevel=single' actually enters runlevel 3 and then adjusts the running services.

In practice I have managed to boot into single user mode using the following boot options:
Code: Select all
init_opts=single
lik
Founder
Founder
 
Posts: 497
Joined: Wed Dec 15, 2010 3:21 am


Return to Linux specific

 


  • Related topics
    Replies
    Views
    Last post
cron