Solved

Changing the Root password

Posted on 2003-10-29
6
1,013 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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
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 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…

867 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

22 Experts available now in Live!

Get 1:1 Help Now