Friday, July 30, 2010
               

You are not logged in.

Repair Central / Tutorials / Linux / Reset Root or User Password

Reset Root or User Password

Reset Root Password By Terry Martin www.imagineitconsulting.net
We all forget passwords.  I've done it myself.  When you setup a test Linux system, you set the root password to something you "should" remember.  But a month later, you come back and need to do something that requires admin privileges, and you can't quite remember the root password.  What do you do?  You don't want to reinstall because it takes too long to reconfigure everything.  Most Linux systems have a "back door" called single user mode.  Ubuntu calls this "Recovery" mode.  When you boot into single user mode, or recovery mode, you will get a root prompt without putting in the root password. Pretty cool.  Also, pretty scary if you happen to gain access to someone else's Linux box.  That is why this doesn't always work.  More on that later. For now, lets get started.    
  1. On boot up, enter the Grub boot menu
  2. If available, enter “Recovery Mode” and let the system boot.  If “Recovery Mode” isn’t available, press “e”.
  3. Move the cursor to the line that begins with “kernel” and press ‘e’
  4. Put a “1” (thats the number one) at the end of this line
  5. Hit “Enter” and press “b” to boot
This will get you to a root command prompt.  You now have two options.    Option #1   You can type:               #> passwd   You will be asked to supply and confirm a new password for root.    Option #2   If you just want to blank out the root password, or any user’s password, you can edit two files: /etc/passwd and /etc/shadow   For the file /etc/passwd, you should see something that looks like this:               root:x:0:0:root:/root:/bin/bash   This is the entry for root.  You should see an entry for every user on the system.  Delete the ‘x’ and save the file.   For the shadow file, you are looking for a similar line, except this time instead of ‘x’, you will see a hashed version of the password.  For example,               root:$1$wKVlXGjM$qd5f/NIuLqGU7p1s32HM1/:13955:0:99999:7:::   Delete the contents in-between the first set of colons. Here it would be the $1$w… string.  Save this file.   The root, or whichever user’s, password is now reset.  Reboot the machine.  Grub will automatically boot into the normal mode.   This method will work on (almost) all Linux Operating Systems, with a couple of exceptions.  Fedora and OpenSUSE used to not allow this. In order to reset the password on these machines, as well as other incompatible ones, you must boot up with a live cd and mount the / (root) partition.  Once it is mounted, you can follow the steps for blanking the password.   There are also other factors that determine if this will work or not.  For instance, how you partition the drive. You may have to mount the partition where /etc is located.   Although this method seems simple and straight forward, and it really is, many things can go wrong and this won't work.   So remeber passwords and ALWAYS backup.

Arcade Contest

Game scores have been reset!
Be the first one to score!
....:::::::::: TIME LEFT ::::::::::....
... to Saturday midnight!