LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   forgotten superuser password reset (https://www.linuxquestions.org/questions/linux-newbie-8/forgotten-superuser-password-reset-792692/)

sourabh.sinha 03-02-2010 01:44 PM

forgotten superuser password reset
 
Hello,
We use a linux (centOS I believe) cluster for our research. My professor somehow forgot the new password he set for root, and now can't login as 'su'. What is the way (or best way) to reset the root password without damaging something. I don't know whether it's even setup for 'sudo'. What will the procedure with and without 'sudo'?
~Sourabh

pixellany 03-02-2010 01:53 PM

The typical method is to boot into single-user mode. I'm not 100% sure that Redhat/Centos lets you do this without a password, but its worth a try.

Start up the computer. When you see the grub menu, then hit any key to stop the count, then:

With the desired entry higlighted, hit "e" for edit.
Select the kernel line, and "e" again
Add the word "single" (no quotes) at the end
hit return (enter), then "b" to boot
The machine should come up in a terminal mode, root account, with no password needed.
Assuming all this works, enter "passwd root", the new password, and then "init 5" to go back to normal. (Or maybe "init 3" with a server?)

If this does not work, the only options I know is to boot the system from live CD, mount the partition containing /etc, and edit the "passwd" file to remove the first "x" in the root entry. This then allows root to login with no password.

ursusca 03-02-2010 01:55 PM

Hi

You have to reboot your box:

Select the kernel
Press the e key to edit the entry
Select second line (the line starting with the word kernel)
Press the e key to edit kernel entry so that you can append single user mode
Append the word Single to the end of the (kernel) line
Press ENTER key
Now press the b key to boot the Linux kernel into single user mode

You need to remount / partition:
Code:

# mount -o remount,rw /
Change the root password, enter:
Code:

# passwd
Reboot system:
Code:

# shutdown -r now
or
Code:

#reboot

sourabh.sinha 03-02-2010 01:58 PM

Thanks,
Is 'init 5' a command? What does it do?
~Sourabh

pixellany 03-02-2010 02:09 PM

"init" is the first program run by the kernel at boot time. You can also use it to change runlevels. /etc/inittab typically tells you what happens in each runlevel.

Suppose I kill X-Windows by entering "init 3". Then I can edit config files, maybe install a new video driver, and then get back to the GUI by entering "init 5"

BUT--the runlevels are not the same on all systems....

chrism01 03-02-2010 08:12 PM

You can use

telinit 1

to get single user mode; should work from the console. Otherwise, try the boot from DVD option and type

linux rescue

at the initial text prompt


All times are GMT -5. The time now is 06:11 PM.