Solved

Changing the Root password

Posted on 2003-10-29
6
1,012 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

This document is written for Red Hat Enterprise Linux AS release 4 and ORACLE 10g.  Earlier releases can be installed using this document as well however there are some additional steps for packages to be installed see Metalink. Disclaimer: I hav…
Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now