UNIX Hints & Hacks |
|||||||||||||||||||||||||||||||||||||
Chapter 5: Account Management |
|
||||||||||||||||||||||||||||||||||||
|
This is a way to clear the root password when you don't have access to the vi editor.
Flavors: AT&T, BSD
If no one has access to the root password on a system and it is a matter of urgency to get into that system, you can boot miniroot and clear the password out of the root account. This can be done even when the vi editor is inaccessible. To do this on a system using the /etc/shadow file, use the ed editor with 13 dots and your problems are solved:
# cp /etc/shadow /etc/shadow.bak
# ed /etc/shadow 1p s/:.............:/::/ 1p w q
Line 1: While in the ed editor, go to the first line of the file.
Line 2: Switch the first occurrence of a field that has 13 characters with nothing. This is the password field.
Line 4: Quit.
You're finished! You swapped out the 13 characters of root's password field with nothing and cleared the password. You can now bring the system to single user and change the root password. The same basic commands can be used on the /etc/passwd file for those platforms that don't support shadow passwords. The result is the same.
As professional UNIX system administrators, you never forget passwords. You can use this hack in situations such as when you inherit a machine on which there was no root password provided when you received the system, and nothing seems to let you in.
In large installations, inheriting old systems is all too common. I remember one instance when we received a system that was running an obsolete version of the operating system. Management wanted the data checked before it was junked. We needed to have a CD-ROM shipped from the East Coast and had our local sales rep hunt one down. Two weeks later we were finally ready to boot miniroot. As we booted miniroot, the owner of the system walked in and asked whether I wanted the root password. After everything I'd gone through, I politely rejected her offer. I'd put so much time into this that I wasn't going to take the easy way out now. Needless to say, I didn't need the password from her, I gained access, and found that there wasn't anything on the disks anyway. All in a day's work, right?
Man pages:
ed
UNIX Hints & Hacks |
|||||||||||||||||||||||||||||||||||||
Chapter 5: Account Management |
|
||||||||||||||||||||||||||||||||||||
|
© Copyright Macmillan USA. All rights reserved.