Solved

Changing the Root password

Posted on 2003-10-29
6
1,021 Views
Last Modified: 2011-10-03
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  
0
Comment
Question by:CMILLER
6 Comments
 
LVL 20

Expert Comment

by:Gns
ID: 9644923
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
0
 
LVL 7

Expert Comment

by:troopern
ID: 9644930
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
0
 
LVL 12

Expert Comment

by:paullamhkg
ID: 9646994
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
0
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 

Author Comment

by:CMILLER
ID: 9647055
Thanks, I will try all sug, I will be out of the office until monday next week, I will try then.
0
 

Author Comment

by:CMILLER
ID: 9723626
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
0
 
LVL 20

Accepted Solution

by:
Gns earned 125 total points
ID: 9730016
su
mount         #<- the mount command is to check that /dev/hda# hasn't been mounted already... If so, just umount <mountpint or device handle>
mkdir /tmp/hdroot
mount /dev/hda2 /tmp/hdroot
mount /dev/hda1 /tmp/hdroot/boot
chroot /tmp/hdroot
passwd
<password>
<password>
--- done ---
Just reboot and you should be able to log in...:)

-- Glenn
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Little introduction about CP: CP is a command on linux that use to copy files and folder from one location to another location. Example usage of CP as follow: cp /myfoder /pathto/destination/folder/ cp abc.tar.gz /pathto/destination/folder/ab…
You ever wonder how to backup Linux system files just like Windows System Restore?  Well you can use Timeshift in Linux to perform those similar action.  This tutorial will show you how to backup your system files and keep regular intervals. Note…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question