home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


Unix Power ToolsUnix Power ToolsSearch this book

49.3. Forgetting the root Password

If a person forgets their password, it's easy for root to reset it using passwd, but what happens if you forget root's password?

Depending on the security implemented for a system, you can log in to single user mode and then use passwd to reset the root password. Or you can manually edit the password file to remove the password for root. Once you reboot and login to the system as root, you can then use passwd to change the password to something more restrictive.

In Redhat Linux, access single-user mode by typing linux single at the boot prompt. In Solaris, enter single-user mode by pressing STOP-a and then typing boot-s at the prompt. FreeBSD boots in this mode by booting with the -s option and then mounting the file system in read/write mode. Check your system documentation to see how to do this for your particular flavor of Unix.

This approach works only if the system doesn't password-protect single-user mode. However, if you have access to the physical machine and the installation disks, booting with the install disk will usually allow you access to the partitions. Once you have this access, edit the password file and remove the root password.

As an example, Debian requires a password in single-user mode. To reset the root password with Debian, put the installation disk into the machine and boot. Mount the /root partition and manually edit the shadow file, setting the password to a blank password. After rebooting into the system, reset the password using passwd.

-- SP



Library Navigation Links

Copyright © 2003 O'Reilly & Associates. All rights reserved.