Lost root password

Kernels & Hardware, configuring network, installing services

Lost root password

Postby Foxtrot » 2005-03-10 00:02

I was using Ubuntulinux and did a full default upgrade in Synaptic using Debian testing repositories. When I restarted my system after doing so, my root password was no longer working, which made me unable to fix the no-longer working network.

If anyone knows what the default password in the testing releases of Debian is, then that would be a great help, as I currently have no way of administering my system. :oops:

Thanks.
Foxtrot
 

Postby lacek » 2005-03-10 14:48

There is no such thing as 'default' root password in (to my knowledge) any Linux distribution.
What you can do, is to boot a 'live' CD, mount your root filesystem, and edit /etc/shadow. The first line of it looks like this:
Code: Select all
root:$1$.mQp/2pK$JPbCEiU.sWxSOiDWuqQfD.:12584:0:99999:7:::

The garbage between the 'root:' and the next colon is the password. Remove it, so you may end up with this line:
Code: Select all
root::12584:0:99999:7:::

After this, you can log in as root with no password.

Also, if you don't have a live CD, add the 'init=/bin/bash' boot parameter to the kernel image you want to start at the LILO (or GRUB) prompt. After you got the prompt, enter this line:
Code: Select all
mount -n -o remount,rw /

After this, you can edit /etc/shadow as previously mentioned.
If your LILO or GRUB is password protected, and you forgot this password, too, then only the live CD boot can help you.

Note that in order to avoid such surprises, you should install the 'sudo' package, with which you can grant root privileges to any user. This way, the user needs to know only his/her password in order to become root. If you had added yourself to sudoers, you weren't in such situation. See the man page of sudo and sudoers for more info.
lacek
Moderator Team Member
 
Posts: 769
Joined: 2004-03-11 18:49
Location: Budapest, Hungary

Postby Jeroen » 2005-03-11 02:43

You can also set the root password by booting with "linux init=/bin/bash" usually, and then use 'passwd' to set the root password

the same can be done from a livecd, boot it, become root, chroot into your system by mounting your root partition and chroot to the mount point, and again, just run 'passwd'.
Jeroen
Debian Developer, Site Admin
Debian Developer, Site Admin
 
Posts: 571
Joined: 2004-04-06 18:19
Location: Utrecht, NL

Postby Foxtrot » 2005-03-12 12:29

Thanks for your help, people, but I've already formatted the drive and reinstalled Ubuntu. Since it turned out that Ubuntu won't boot anymore not matter the installation, I'm trying to find another distro. :)

Thanks again.
Foxtrot
 

Postby pylonx » 2006-10-12 19:08

Thank you!

I'm new to debian. New to linux all together but I am catching on. I just replaced the Manager of Information Systems where I work. They fired him before I had a chance to learn what he was doing. He left no sign of what any of the users were nor root password. So, just letting you know this has helped. I hope I'll like debian as much as I have liked slackware.
pylonx
 
Posts: 1
Joined: 2006-10-12 18:17

Postby beissemj » 2006-10-13 01:41

chroot is probably your best bet. Quick 'n dirty. Just to clarify what Jeroen said:
1. Boot with a livecd (knoppix, gentoo, dsl, whatever)
2. mount your root partition (i.e. mount /dev/hda4 /mnt/directory)
3. chroot /mnt/directory
4. /bin/bash (or whatever your shell is)
5. passwd

This is why physical access always means people can get whatever is on your computer, regardless of whether you have a root password or not.
Their is no such thing as a stupid question... They are just the easiest to answer.

Howto setup Debian on a Dell Latitude D600 http://d600.elwiki.com
beissemj
 
Posts: 38
Joined: 2006-07-19 13:53

Postby Richard_Davies » 2006-10-26 00:38

Slight weirdness on my system AMD64 running etch. I have just lost the root password but only for graphical things, setting the clock on KDE and starting synaptic from the menus but it will still let me into the networking configuration screens. From the command line I can su to root with no problems. It is very odd.
Richard_Davies
 

Postby ElTopo » 2006-10-26 03:27

for ubuntu your normal user is in /etc/sudoers, so you can just log in as the normal user and do

sudo passwd

or

sudo su

to become 'root'
ElTopo
 
Posts: 19
Joined: 2006-08-06 22:14

Postby plugwash » 2006-10-27 20:08

btw provided your bootloader is not locked down changing the root password is easy.

add init=/bin/sh to the kernel command line (in lilo just type it after the image name, in grub i think you press E)

the thing will start booting but pretty quickly will drop you at a shell from that shell do the following

mount -o remount,rw /
passwd root
(enter the new password)
exec init

your system will now continue booting normally and when it boots you should be able to use your new root password.

note: if you use kdm (and possiblly other greeters) the version now in debian testing won't let you log in as root, if this bothers you then you can edit /etc/kdm/kdmrc.
plugwash
 
Posts: 2426
Joined: 2006-09-17 01:10


Return to System configuration

Who is online

Users browsing this forum: noop and 1 guest