How to retrieve root password

Even if I never forget any passwords, I would still study this issue in detail because it can give me a hint on how my mother might be reading my ICQ chats history :-)

First method. The easiest way to solve your "forgoten root password" problem is to boot your Linux in the single-user mode, namely at the "lilo"prompt (during bootup) type: 

linux single

This will make you "root" without asking for password. Now, being root, you may change the root password using this command (no knowledge of the old password required): 


If it strikes you as insecure, that’s because no computer system is secure if other people have physical access to your hardware. Nevertheless, I did not like the "linux single" hole on my home computer and plugged it by adding the following lines to my /etc/lilo.conf file (at the end of the
"image=" section):


This "lilo" password is required when, at the LILO prompt during bootup, somebody enters the word "linux" with any parameter (normal bootup without any parameters will still be possible without a password).] For the changes to /etc/lilo.conf to take effect, I must re-run the command lilo . Since my lilo password is not encrypted, I must make /etc/lilo.conf readable only for root: chmod 600 /etc/lilo.conf 

Second Method. Another way to solve the "lost-root-password" problem is to boot your computer from the Linux boot diskette, find your Linux root partition on the hard drive, mount it, and edit the file /etc/passwd. (I can do it because after booting from the floppy, I become root without being asked for a password.) In the password file, I erase the encrypted password for root, so it is empty. For example, the /etc/passwd entry for root may look like this: 


The "abcdefghijklm" is a 13 character encrypted password (actually, it is a 2 character "salt" used for encryption and a 11-character encrypted password). I would change this line to: 


Now, the root account has no password, so I can reboot the computer and, at the login prompt, type "root" and for password just press ENTER (empty, no password). After a successful login, I immediately set the password for root using the command: 


The above applies to traditonal UNIX and RH5.2 password files. In newer systems (e.g., RH6.0 and RH6.1), a more secure setup is used which utilizes a shadow password file. In this case, the file /etc/passwd contains just an "x" in the field where encrypted password used to be traditionally stored. The encrypted password is stored in the file /etc/shadow . [This increases the security because of the different permissions on the files: the file /etc/passwd can be read by anybody but /etc/shadow cannot. Additionally, the shadow password system allows passwords longer than 8 characters, and adds extra goodies like password expiry policy, etc.] As root, you can manipulate the file

/etc/shadow as you would /etc/passwd .

To make the "floppy access" to my system a little bit more difficult, I considered running a computer without a floppy drive :-) Unfortunately, Linux CDs are bootable these days. I set up my boot sequence (in the BIOS setup) so that the system boot from the hard drive before floppy and CDROM are tried, and added an "administrative" password on changes to the BIOS settings. Still, I worry that these BIOS passwords are so easily crackable and also one could remove my harddrive and connect it to another computer for reading :-) . I am considering an "encrypted file system" which is now available on Linux, but considering all the trouble associated with it, perhaps I will settle on locking my room :-) . If all this sound paranoid to you, it probably is--it just illustrates the point there is little computer security, even under Linux, if the potential cracker has physcial access to your hardware.

Posted on: 14/12/2009

If you want to leave a comment please Login or Register