Thank you for being a valued part of the CNET community. As of December 1, 2020, the forums are in read-only format. In early 2021, CNET Forums will no longer be available. We are grateful for the participation and advice you have provided to one another over the years.

Thanks,

CNET Support

General discussion

2/23/04 Linux: Lost my root password

Feb 20, 2004 2:16AM PST
Question
Help! I'm running Linux on my PC, and I've lost my root password. Is there anything I can do?

Answer:
1. Boot up the system from the CD or floppy disk.
2. Mount the /root partition.
3. Edit the /etc/shadow (or /etc/passwd if this file doesn't exist (it wasn't there in older versions of Linux).
4. Find the line starting with root and delete anything between the first and second colon (Happy
5. Reboot; the root password is now blank.
6. Remember to set a new password when you log in!

Submitted by: Ben B
Congrats Ben B. and thank you for your great submission!

This week I also have a few honorable mentions that I would like to share with you, they are as follows:

Answer:

If you forgot you root password in Linux, you can reboot your PC and wait
for the boot prompt.

If you are using LILO as your boot loader, you can enter "linux single" in
the "lilo:" prompt. If you are using GRUB, press the letter "a" at Grub's
boot screen so you can add to the boot parameter. after pressing "a", you
can add "single" to the boot parameter.

After this you will be booted to a single user mode of linux. you can
change to a new password by typing "passwd" and change the root password to
something you will remember.

After successfully changing the password, you can either type "exit" or
press "Ctrl-D" to boot to run level 3 or multi-user mode. You can also
enter "Shutdown -r now" to tell! your PC to shutdown and reboot now. Or you
can use the three finger salute "Ctrl-Alt-Del".

Submitted by: Dem C from Hong Kong

************************************

Answer:

Yes! As long as you have direct access to the PC and are not trying to reset
a remote machine. If you installed using GRUB, at the menu select "a" after
selecting Linux. This will place you into single user mode with all
privileges. Now you can just change your password and reboot. If you are
using LILO the procedure is the same only type ctrl-x at the OS boot
selection menu and type linux 1. Then reset your password.
You can also rest the password by using the editor "vi" and manually editing
the "/etc/passwd" (you may also have to edit the "etc/shadow" file. Delete
the reference to the root password. To do this remove the password field:
by deleting everything just beyond the first ":" and the next ":" after the
word root. Exit vi with ":wq!" so that you save your changes.
If you do not have access to GRUB or LILO, or your system will not allow you
to use single user mode, you can reach the files using your rescue disc (if
you have one or you can use one of the many LIVE CD versions like Knoppix
(www.knoppix.net) or Damn Small Linux (www.damnsmalllinux.org). These will
give you access to your machine without affecting your hard drive. You can
then manually edit the "passwd" file and/or the "shadow" file.

Submitted by: Peter R from Latham, NY

************************************

Answer:

First retrieve the little sticky note that is securely hidden behind your monitor; --the one on which you also wrote your ATM card pin and the online access code for your retirement plan. If the sticky note is missing you should dig up the OS installation CDs; now, is also a good time to cancel your credit cards. You most certainly wrote the password in permanent marker on the face of the OS installation CD or the CD case. However, you may now recall that there are no permanent markers in your office, just dry erase; --the password is undoubtedly smeared beyond recognition. Just insert the CD into the drive to run the recovery app. Most likely you will now encounter one of two things: (1)the CD is actually a CDRW that you burned on a recently replaced drive. It is unreadable to the current drive and therefore the recovery app. is unavailable or (2) You also protected your computer with a boot password (which you kept the same as the root password for ease of memory)and the recovery app. is unavailable. No worries, just run down to "happy jacks PC stuff" and buy a new 100gig drive for $60.00; --It is an unfortunate expense, but far less than further headaches. Surely you will now be able to restore that last known good OS image and data backup to this new drive and will be back in business in no time at all. Of course, you'll need to find the key to the security cable on your computer case....

Submitted by: Charley C. from Radford, VA

Good one Charley! Grin

Thank you everyone for taking time out to submit your answers and questions for last weeks Q&A. Look forward to hearing from all of you this week.

Best regards,
-Lee

Discussion is locked

- Collapse -
Re:February 16, 2004 Membership Q&A Newsletter
Feb 23, 2004 12:36AM PST

I don't run Linux but am interested in the subject as I consider switching my home systems. So by the answers to Ben question, what is to stop me (being the evil voice here) from going to any computer in my organization (especially ones I should be at) with this boot CD and replacing the root password?

- Collapse -
Re:February 16, 2004 Membership Q&A Newsletter
Feb 23, 2004 12:37AM PST

I don't run Linux but am interested in the subject as I consider switching my home systems. So by the answers to Ben question, what is to stop me (being the evil voice here) from going to any computer in my organization (especially ones I shouldn't be at) with this boot CD and replacing the root password?