System Administration Guide: Advanced Administration
Previous Next

What to Do if You Forgot Root Password

If you forget the root password and you cannot log into the system, you will have to do the following:

  • Stop the system by using the keyboard stop sequence.

  • Solaris 10 1/06 On x86 based systems, boot the system in the Solaris failsafe archive.

  • Solaris 10: Boot the system from a boot server or an install server, or from a local CD-ROM.

  • Mount the root (/) file system.

  • Remove the root password from the /etc/shadow file.

  • Reboot the system.

  • Log in and set root's password.

These procedures are fully described in Chapter 12, Booting a System (Tasks), in System Administration Guide: Basic Administration


Note - GRUB based booting is not available on SPARC based systems in this Solaris release.


The following examples describe how to recover from a forgotten root password on both SPARC and x86 based systems.

Example 18-1 SPARC: What to Do if You Forgot Root Password

The following example shows how to recover when you forget the root password by booting from the network. This example assumes that the boot server is already available. Be sure to apply a new root password after the system has rebooted.

(Use keyboard abort sequence--Press Stop A keys to stop the system)
ok boot net -s
# mount /dev/dsk/c0t3d0s0 /a
# cd /a/etc
# TERM=vt100
# export TERM
# vi shadow
(Remove root's encrypted password string)
# cd /
# umount /a
# init 6
Example 18-2 x86: Performing a GRUB Based Boot When You Have Forgotten the Root Password

Solaris 10 1/06: This example assumes that the boot server is already available. Be sure to apply a new root password after the system has rebooted.

Press any key to reboot.
Resetting...

 GNU GRUB  version 0.95  (631K lower / 2095488K upper memory)

 +-------------------------------------------------------------------------+
 | Solaris 10.1 nv_14 X86                                                  |
 | Solaris failsafe                                                        |
 |                                                                         |
 |                                                                         |
 |                                                                         |
 +-------------------------------------------------------------------------+
 

 GNU GRUB  version 0.95  (631K lower / 2095488K upper memory)

 +-------------------------------------------------------------------------+
 | root (hd0,2,a)                                                          |  
 | kernel /boot/multiboot -B console=ttya kernel/unix -s                   |
 | module /boot/x86.miniroot-safe                                          |
 |                                                                         |
 |                                                                         |
 |                                                                         | 
 +-------------------------------------------------------------------------+

 Booting command-list

root (hd0,2,a)
Filesystem type is ufs, partition type 0x000000bf
kernel /boot/multiboot -B console=ttya kernel/unix -s
[Multiboot-elf, <0x1000000:0x13f3b:0x3941d>, shtab=0x104e258, entry=0x100000
0]...
module /boot/x86.miniroot-safe
SunOS Release 5.10.1 Version snv_14 32-bit
Copyright 1983-2005 Sun Microsystems, Inc.  All rights reserved.
Use is subject to license terms.
Booting to milestone "milestone/single-user:default".
Configuring devices.
Searching for installed OS...
        /dev/dsk/c1t0d0s0 --       Solaris 10.1 nv_14 X86

Do you wish to automatically update boot archives? [y,n,?] n

#mount /dev/dsk/c0t0d0s0 /a
      .
      .
      .
# cd /a/etc
# vi shadow
(Remove root's encrypted password string)
# cd /
# umount /a
# init 6
Example 18-3 x86: Booting a System When You Have Forgotten the Root Password

Solaris 10: The following example shows how to recover when you forget root's password by booting from the network. This example assumes that the boot server is already available. Be sure to apply a new root password after the system has rebooted.

Press any key to reboot.
Resetting...
.
.
.
Initializing system                                                             
Please wait...                                                                  
                                                                                
                                                                                
                     <<< Current Boot Parameters >>>                            
Boot path: /pci@0,0/pci-ide@7,1/ide@0/cmdk@0,0:a                                
Boot args:                                                                      
                                                                                
Type    b [file-name] [boot-flags] <ENTER>     to boot with options            
or      i <ENTER>                              to enter boot interpreter       
or      <ENTER>                                to boot with defaults           
                                                                               
                  <<< timeout in 5 seconds >>>

Select (b)oot or (i)nterpreter: b -s
SunOS Release 5.10 Version amd64-gate-2004-09-30 32-bit
Copyright 1983-2004 Sun Microsystems, Inc.  All rights reserved.
Use is subject to license terms.
DEBUG enabled
Booting to milestone "milestone/single-user:default".
Hostname: venus
NIS domain name is example.com
Requesting System Maintenance Mode
SINGLE USER MODE

Root password for system maintenance (control-d to bypass): xxxxxx
Entering System Maintenance Mode
.
.
.
# mount /dev/dsk/c0t0d0s0 /a
      .
      .
      .
# cd /a/etc
# vi shadow
(Remove root's encrypted password string)
# cd /
# umount /a
# init 6
Previous Next