Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I lost the Linux Password(root)

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
0
0
I am working with Suse 6.3, but i dont have the root password. The person that made the server, he isnt here in
the company and wishes that I pay for him , for he tell me
the password. Is there a way that I can discover this
password?

Thanks

Ely Alves
 
Don't pay him squat. I have an article (unfortunately it's at home) that shows how to reset the root password if you've lost it. I will be glad to help you out. I'm currently trying to find the article online, but I don't remember exactly what site I got it at. Be patient, you'll have you're answer at least by Monday, but please e-mail me, I'd rather not post something like how to reset a root password on a public forum even though the information is available from this article. If I find the article I'll post the URL to it on this thread. d3funct
borg@pcgeek.net
The software required `Windows 95 or better', so I installed Linux.

 
i'm not sure, but i think you can type linux 1 when lilo comes up, which should let you login with no passwd. i think you can then change the passwd. i'm not sure, and have no way to test it, but, i think that works. adam@aauser.com
 
The problem is some of the newer distributions have a password even in the single user mode (SuSE 6.x is one of them...)

Here is a way that should work on SuSE -- the only caveat is there is no clean way to shutdown the system after you do it (you have to do a hard reset, 'reboot' or Ctrl-Alt-Del -- which causes it not to shutdown properly..., but 'shutdown -h/r now' does not work...)

Having said that and given you the warnings of a non-standard shutdown....

Reboot your system - at the LILO prompt and type 'linux init=/bin/bash'. Once you are at the 'init-2.02#' prompt, type 'mount -n -o remount,rw /'. Next type 'passwd' and change your password. Now reboot your system (hard reset, 'reboot' or Ctrl-Alt-Del) and you'll be back in business.

Hope this helps and use this only as a last resort since there is a chance of file system corruption -- MAKE SURE you have a good backup before attempting this!!!!!

Also, before you try this - you might try and do a net search (via for 'lost root password linux' and you might come up with some cleaner ways. But 'linux single' on SuSE systems (at least mine...) required a password to get access...

Hope this helps,
Paul
 
hi paul,

i am not sure whether the restricted mode of lilo comes with default. And even if it does do you have a entry for "password = xxxxx" in your /etc/lilo.conf along with the key word "restricted"!

else lilo would boot normally with "linux single" or "linux 1" or whatever your_image_names_is followed by single or 1.

another method is to use a boot up floppy to boot in to linux.. although not many people make such a floppy (a pair actually) at install time... u can always make a similar dummy installation on another m/c and use that to boot in to ur system in single user mode.

hth,
shail
 
What I have found most successful is a single floppy Linux distribution called "tomsrtbt", at
What you do is boot up with this floppy, which creates a ram disk of a standard Unix filesystem.

1. create a directory, such as /myrescue
2. mount the main hard drive to that directory, using /dev/hda1 (or whatever your drive is, you might want to try hda2, hda3, etc...). So it would look like this:

mount -t ext2 /dev/hda1 /myrescue (You might review the mount command at before doing this for more details)

3. after you have successfully mounted the hard drive to the /myrescue location, you want to cd into /myrescue/etc and open the passwd file. There you will see a list of users with encrypted passwords. Don't worry about that. All you want to do is delete the root user's password completely, so you will see a line such as:

root:kjEKfInme549jsdkj:0:0::0:0:Root User:/root:/bin/bash

Just delete everything between the first and second colon, and root will now have no password. Then when you reboot your system you can log in as root and you won't be asked for a password. Please be sure to set a new password for root immediately.
 
what if you are using shadow passwds? will this still work? adam@aauser.com
 
Here are the instructions into breaking into your own system if you've lost your root-password. This is taken from an article I found in Linux Gazette, written by Mark Nielsen (
This document assumes you are partitioned thusly:
/dev/hda1 swap
/dev/hda2 /
/dev/hda3 Dos

Author refers to Redhat 5.2 but this will work with subsequent versions (I've tested it).

Steps:

1. Make system bootable from CD-rom (either in BIOS or use a boot floppy that will do so).

2. Put Linux Distribution CD into cd-rom drive and turn on computer.

3. Pretend to go through installation of distribution and after it asks you to put in the CD-rom and it gets to the next screen you can now go to the second console window.

4. Press Alt-F2, Alt-F3, Alt-F4, Alt-F5 and then Alt-F1. You should see the various screens with different messages. The one we want is Alt-F2.

5. Press Alt-F2.

6. Type "cd /tmp" and press enter. This takes us to a directory where we can make files, directories, etc...

7. Now we will make a temporary directory and a temporary device for the partition on the hard drive that we want to look at or edit. Type the following:
mkdir /tmp/my_dir
mknod /tmp/my_dev b 3 2 #the two is taken from hda"2" above, so should
be wherever your "root" partition is.
mount /tmp/my_dev /tmp/my_dir
df

8. "mkdir" makes a directory for us to mount the a partition to. "mknod" makes a device for 2nd partition on the master hard drive (hda2). This lets us "see the partition. In particular, "b 3 2" means "b" is for block device, "3" is the master hard drive on the primary IDE controller and "2" means the second partition.
"mount" takes the device we can "see" and puts it on top of the directory /tmp/my_dir.
"df" lets you see what filesystems are mounted and where.

Now we can iether edit the password file or perhaps something like turning off xwindows from starting up if you have a computer using xdm. Let's do the password

9. type: "cd /tmp/my_dir/etc" then "vi passwd"

10. You need to know how to use vi (a great editor found on almost every UNIX by default). "x" deletes a character, "i" inserts characters, "Esc" turns on and off command mode/insert mode, "wq!" writes, quits and ignores any problems with read-only files, "h" moves one character to the left, "l" one character right, "k" up one line, "j" down one line.

11. Now in the passwd file press "j" until you get to the line you want to be on "root" (for our example)
root:x:0:0:root:/root:/bin/bash # here we want to delete the "x" which is telling
us the password is shadowed.
now type "wq!" (without the quotes)

12. Now type "vi shadow"

You may see a line for root that looks like this

root:$1$Upkf7iIA$.nSNmn0MkoRP2srJsUx.0/:11321:0:999999:7:::
just delete everything between the colons to make it look like
root:::::::: # that's 8 (eight) colons after the word "root"

now type "[Esc], :, wq!, enter" to write the file, quit and ignore read-only problems.

13. Now your done editing the file, what is the problem now? If you reboot you will likely lose all of your changes. You must unmount the directory, THEN reboot.

14. Do this > "cd /tmp" > "umount /tmp/my_dir" > "df"

15. After ensuring you unmounted ok, press CTRL-Alt-Del to reboot. Also, take the cdrom out fo the cdrom drive. When your computer restarts I'd recommend having your BIOS boot off the hard drive rather than the CD-rom.

That's it, this is very useful in the case of lost/forgotten root passwords. But it's also good for fixing other problems when you just can't get it booting the right way. As I said, I plagarised the hell out of his article. But it was a great article and helped me out immensly. I hope Mr. Nielsen doesn't mind my copying his work for this forum. :) d3funct
borg@pcgeek.net
The software required `Windows 95 or better', so I installed Linux.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top