Operating System - Linux
1820274 Members
3296 Online
109622 Solutions
New Discussion юеВ

I forgot my root password

 
Charles Egbon
Regular Advisor

I forgot my root password

Dear Friends,
I have suse 8.2 Linux installed on my network. I forgot my root password. How do I regain root permission? Also, how do I boot to single user mode?
Thanks

Charles
10 REPLIES 10
Sergejs Svitnevs
Honored Contributor

Re: I forgot my root password

Jan Sladky
Trusted Contributor

Re: I forgot my root password

Hi Charles,
fastest way is following

reboot

issue init=/bin/bash like kernel parameter (before loading kernel)

mount -n -o remount,rw /

passwd

and that's all

rgds Jan
GSM, Intelligent Networks, UNIX
Steven E. Protter
Exalted Contributor

Re: I forgot my root password

On most distributions, single user mode is done by keyboard intervention at the console on the console. You do need the root password for this.

Kind of a circle.

What you can do is boot off of a special emergency cd/disk that you created at install time. With this you may be able to edit the /etc/shadow file and null out the root password.

Then there will be no root password, so you will have to immediatly log on and set it.

Downtime required.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
NiCK_76
Respected Contributor

Re: I forgot my root password

Hi Egbon,

boot system with single mode and perform command "passwd" to change password.

NiCK
just for fun
Wim Van den Wyngaert
Honored Contributor

Re: I forgot my root password

Nicks solution works on Redhat 7.2 Alpha.
It doesn't ask for the old password and no login is needed.

Wim
Wim
TwoProc
Honored Contributor

Re: I forgot my root password

Charles,
If you're using grub...

interrupt the grub loader (hopefully you've got a pause there) by just hitting the arrow key around at the menu choice for the grub loader - this will make the timer countdown stop.

Then,
go to the line that holds your choice of the Linux load you want and hit "e" (for edit). This will bring you into an editor for the current load command. Choose the line you want ( I can't remember which one you need off the top of my head - there's probably two - try it on both), and hit "e" once again. Now, you should be editing a single line of the loader. Arrow key to the end of teh command and and the parameter "single" to the end of the line. Hit enter to "save" (only in the buffer - not on the disk) the command.
At this point - I think you hit "B" to boot it (read the screen).

System should boot into single user mode - needing no password. Change your password with the password command.

BTW, this is all a very good reason to lock your cabinet(s) for your servers and/or use bios password protection to boot the server, AND have a keypad lock on the server room...
We are the people our parents warned us about --Jimmy Buffett
Charles Egbon
Regular Advisor

Re: I forgot my root password

Thanks Guys for all your contributions!

I was able to change the root password on single user mode but I can't log-in as root on the multiuser mode. I tried manipulating the /etc/passwd file, because, I discovered that there is no entry for root shell, even as root in the single user mode, all I get is the that - this file is read only. I check the file as root, the permission is 644. What do I do next?

Charles
TwoProc
Honored Contributor

Re: I forgot my root password

Sorry, all you've got is the ability to lay your hands on the machine and change password from single user. That file is supposed to be protected from change by anyone other than root - otherwise you'd have ALL sorts of security problems. Single user mode is it. This is how the machine protects itself from just anyone telneting in and changing security w/o superviser access.
We are the people our parents warned us about --Jimmy Buffett
B. Hulst
Trusted Contributor

Re: I forgot my root password

Hi,

If you have shadow passwords in use then it is no use to edit the /etc/passwd file.

You should erase the password field from the shadow password file. Could be named /etc/shadow or similar in linux flavors...

Regards,
Bob
Dave Falloon
Trusted Contributor

Re: I forgot my root password

Charles,

I have no more to add to the solutions of others, the way I've rooted boxes in the past has already been outlined:

boot single user
mount / rw
remove all the hashed characters in /etc/shadow for the root user
reboot login as root and run passwd to set a new pass

What I suggest beyond the solution is the prevention of this happening again. The command sudo is great for this kind of thing. Here is a mini howto outlining the steps for using sudo.

http://www.chinalinuxpub.com/doc/www.siliconvalleyccie.com/linux-hn/sudo.htm

Hope that helps,

--Dave
Clothes make the man, Naked people have little to no effect on society