Recovering from a lost root password

If you have lost or forgotten the root password on your Sun Sparc system here are some instructions for regaining control of the system.

You will need a cdrom drive and a Solaris installation cdrom. Just to be safe make sure the installation cdrom is equal to, or later than, the OS release on the hard disk.

Determine the root partition, df -k will give you the information you need.

If the system is not halted then halt the system by pressing Stop-A. This will bring you to the ok prompt.

Place the installation cdrom in the cdrom drive. Boot the system to single user mode using the cdrom drive. Type

It may take a while but you will automatically be logged in as root in single user mode running the OS from the cdrom.

If you had to force halt the system, by pressing Stop-A for instance, then the partitions on the hard disk will not be marked as being shutdown cleanly. So I recommend running fsck on the root partition.

e.g. fsck -y /dev/dsk/c0t3d0s0

Now c0t3d0s0 is just the root partition in this example. Please verify your boot disk.

Now mount the root partition. The cdrom has created a directory a for mounting hard disks. So type

mount /dev/dsk/c0t3d0s0 /a

The next step is to remove root's password. Using your favorite editor, edit /a/etc/shadow. Find root's entry in the file and make the second field null. Colons are the field delimeters. So your entry, after changes, should look something like

root::10565::::::

Various fields will be used if certain parameters have been set for the OS.

Now boot to single user mode using the hard disk.

reboot -- -s

NOTE: that is reboot space hyphen hyphen space hyphen s.

You can login as root without a password and set root's password using the passwd command.

Finally, exit single user mode and let the system continue booting to multi-user mode.

I recommend rebooting to single user mode first because if the system is set to not allow null passwords you may not be able to login as root with a null password in multi-user mode.


This web page is Copyright © 1997 - 2017, Stephen Hinchey
If you have comments or additions for these web pages please direct them to webmaster @ barbary.com