LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-02-2010, 01:44 PM   #1
sourabh.sinha
LQ Newbie
 
Registered: Mar 2010
Posts: 14

Rep: Reputation: 0
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
 
Old 03-02-2010, 01:53 PM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
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.
 
Old 03-02-2010, 01:55 PM   #3
ursusca
Member
 
Registered: Sep 2008
Location: Toronto, ON, Canada
Distribution: Gentoo, RHEL (Fedora, CentOS, OEL), Ubuntu, FreeBSD, Solaris 10
Posts: 170

Rep: Reputation: 34
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
 
Old 03-02-2010, 01:58 PM   #4
sourabh.sinha
LQ Newbie
 
Registered: Mar 2010
Posts: 14

Original Poster
Rep: Reputation: 0
Thanks,
Is 'init 5' a command? What does it do?
~Sourabh
 
Old 03-02-2010, 02:09 PM   #5
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
"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....
 
Old 03-02-2010, 08:12 PM   #6
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 7.7 (?), Centos 8.1
Posts: 18,174

Rep: Reputation: 2681Reputation: 2681Reputation: 2681Reputation: 2681Reputation: 2681Reputation: 2681Reputation: 2681Reputation: 2681Reputation: 2681Reputation: 2681Reputation: 2681
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Xubuntu reset forgotten passwords knowland74 Linux - Newbie 1 02-25-2009 10:30 PM
Forgotten Password Love_0 SUSE / openSUSE 3 08-31-2007 08:46 AM
if the root password is forgotten..... AnimaSola Linux - Software 1 05-31-2005 10:12 PM
How to reset forgotten root password comprookie2000 Linux - Newbie 4 10-28-2004 12:33 PM
forgotten password ronss Linux - Distributions 4 04-01-2003 09:02 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:22 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration