Link to home
Start Free TrialLog in
Avatar of Chris Miller
Chris MillerFlag for United States of America

asked on

Changing the Root password

I have a linux computer in my department that has had the root password changed,
and I can not login.

How can I get the password changed.

If you could explain it by doing it at the computer level and if possible over the network  
Avatar of Gns
Gns

Over the network? No. You could visit your local root-kit depot, but I'd recommend against any such thing;).

Hands on the HW? Yes, there might be several ways:
Mainly older distros might come with an "unprotected" singel user mode (usually runlevel 1, on systems with sysV init, s or singel might work with BSDish inits). In that case you simply reboot the machine (perhaps by a "double-kingston" (highlevel technical term from an era when "non-original" memory wasn't that reliable... means "button off->button on":-), and at the boot prompt enter either "1" or "singel" as a kernel commandline option (LILO: <bootlabel> 1<Enter>. Grub, you might have to "e"dit, or "a"ppend...). If you get prompted for the root password, you are out of luck with this method, else just do a passwd (or a passwd root) and you should be fine.
If that didn't work, the simplest thing is to boot some form of rescue mode (most distros have it on the install CD media), or some other linux (toms root&boot from http://www.toms.net/rb is a good floppy-linux, while knoppix (http://www.knoppix.net) is a very nice CD-selfcontained-linux). You need become root (if you arenät already) on that "rescue mode", then mount your on-disk linux "somewhere"... say /somewhere, then you need "chroot /somewhere", passwd ... and you're fine.
fdisk -l on the disk(s) will show what partitions you have... just mount the "Linux" or "Linux Native" ones, find the on-disk /etc/fstab, and you should be able to see what you need mount where (/ on /somewhere, /boot on /somewhere/boot, /usr on /somewhere/usr etc etc).

If you hadn't gathered it before, this is one of the reasons one should have good physical access protections to the server room (locks and alarms).

-- Glenn
A simple way is to use a rescue disc or boot from installation cd and mount the system correctyl and then chroot to the environment and when thats done you can easilly change password with the command passwd
if the method of chroot don't work, boot up by using the knoppix as Gns suggest, try to mount the /etc and modify the /etc/shadow file as below
change the entry 'root:$1$ve.2WRaU$F8FZqVNwcgQftsnWCG5Ig0:12202:0:99999:7:::'  to 'root::12202:0:99999:7:::' this will remove the root password, so after you reboot the original linux, there will be no root password, after login as root (without the password) add the root password by 'passwd' or 'passwd root'.

ps before you edit/modify the /etc/shadow make a backup cp /etc/shadow /etc/shadow.bak will do, just in case anything go wrong, you still can go back to the original
Avatar of Chris Miller

ASKER

Thanks, I will try all sug, I will be out of the office until monday next week, I will try then.
I downloaded KNOPPIX, booted up and su to root.

I did a fdisk -l and have

/dev/hda1 - boot
/dev/hda2
/dev/hda3 - swap

not sure how to mount hda2, I tried " #mount /dev/hda2/etc /
It will not mount
ASKER CERTIFIED SOLUTION
Avatar of Gns
Gns

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial