Accidental Deletion of Root Account

I had created a root account when I installed the Centos 5 into my system.

But now the problem I'm facing is that I accidently deleted the root user account in my system. 

Is there a way to recreate the root account in the system now, without reinstalling the OS?

Solution:

How did you delete the root account? Do you still have an open session for root?

If not, you'll have to boot using the installation media to "Rescue Mode" (or something similar). Mount the root device of the system as read-write.

In both cases, add/modify the line for root in /etc/passwd to read (change the shell if needed).

Code:
root:x:0:0:root:/root:/bin/bash

and this line for /etc/shadow (enter the second field EXTACTLY as shown:

Code:
root:$1$UbSkbnqO$Wjpj2enKcnl8q8dLRjezq/:14574:0:99999:7:::

This should reset the password for root to "p4ssw0rd" (without the quotes, that's a zero, not an uppercase O)

---

I'm attempting to blank out the root user password on a machine that we have forgotten the password for. I have been using the advice posted on this site to boot from CDROM in single user mode, then mounting the root slice and editing the /etc/shadow file. Each time I save the shadow file and reboot the machine, I am still unable to login. After which I go back into single user mode only to find out that the /etc/shadow file is back to its original state and it appears as if I never changed it. Is this being caused by the automounter daemon? If so, how do I turn the automounter off in single user mode? 

Solution:

When you mount the root slice, you need to edit /mnt/etc/shadow or something. /etc/shadow is in memory if you boot from cdrom.

Have a Unix Problem
Unix Forum - Do you have a UNIX Question?

Unix Books :-
UNIX Programming, Certification, System Administration, Performance Tuning Reference Books

Return to : - Unix System Administration Hints and Tips

(c) www.gotothings.com All material on this site is Copyright.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
All product names are trademarks of their respective companies.
The site www.gotothings.com is in no way affiliated with or endorsed by any company listed at this site.
Any unauthorised copying or mirroring is prohibited.