LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Need to recover or change root password. And must run "nano". (https://www.linuxquestions.org/questions/linux-newbie-8/need-to-recover-or-change-root-password-and-must-run-nano-569232/)

ShellyCat 07-14-2007 03:18 AM

Need to recover or change root password. And must run "nano".
 
I hate these darn laptop keyboards! I typed my password very carefully, but yet I must have typed it wrong.

I tried booting from the install DVD, but I don't really know where to find (or how to distinguish) the filesystem on my computer's installation. I looked in "/etc/shadow", but I am not looking at the correct one...that one has no password, so that must be the DVD one. How do I find the "/etc/shadow" on the installed system?

I am aware I won't be able to read the password in "shadow" because it is encrypted, but I should be able to just delete it, correct?


Related: How do I run "nano" from the DVD, but open a file on my own system?

AceofSpades19 07-14-2007 03:20 AM

there is a grub cheatcode that allows you to log into root without the root password, I forget what it is but some googling should turn it up

ShellyCat 07-14-2007 03:51 AM

I do not have Grub, I have LILO.

Hmm, I wonder if you can do that in LILO.

Anyway, probably easier just to edit the "/etc/shadow" on my new system. Problem is I can't tell where it is, and I'm only looking at the one on the DVD.

ShellyCat 07-14-2007 03:58 AM

Found a link, we'll see what happens.
 
Thanks, Ace, I didn't know you could do anything like that. Actually, that's scary...anyone could wipe out your password when you're not looking...granted, you can do the same back!

For anyone else with this same question, the link is:
http://linuxgazette.net/107/tomar.html

And, for LILO, it says:

Follow these steps to reset the password when using LILO:

* Reboot the system. When you see the LILO: prompt (see Fig. 1 below), type in linux single and press 'Enter'. This will log you in as root in single-user mode. If your system requires you to enter your root password to log in, then try linux init=/bin/bash instead.
* Once the system finishes booting, you will be logged in as root in single-user mode. Use passwd and choose a new password for root.
* Type reboot to reboot the system and then you can login with the new password you just selected.

If you have a new version of LILO which gives you a menu selection of the various kernels available press Tab to get the LILO: prompt and then proceed as shown above.

ShellyCat 07-14-2007 04:04 AM

No go on above cheat code.
 
Whether I use "linux single" or "linux init=/bin/bash", LILO tells me "no image by that name".

Tried booting from DVD and entering "linux rescue" there, same error.

Tried USB stick, but I'm not sure that the boot-disk creation on the USB even suceeded in the first place. Same error.

I will try Knoppix approach when I wake up (I am too tired now), but one thing I am confused about in the instructions is this:

Quote:

* Type mkdir mountplace to create a directory called 'mountplace'. This is where we will mount the filesystem.

* Type mount /dev/hdaX mountplace, where /dev/hdaX is your root partition. More information on Linux partitions is available here.
My hard drive was "sda" (SCSI) in the partition table in fdisk when I created the partitions before install. It had 6 partitons (3 primary, 1 extended, 2 logical). Now, I only see "hda5" (which is not the Linux boot)! Any thoughts?

Junior Hacker 07-14-2007 10:40 AM

Not sure if this thread will have an answer, but worth looking at:
http://www.linuxquestions.org/questi...d.php?t=535701

ShellyCat 07-14-2007 12:01 PM

That is what I want to do, but I don't know how.
 
Using the link above, I see the person was directed to do the same thing I am trying to do:
Quote:

Since you have physical access, boot Knoppix or any live Linux CD/DVD), open a terminal, and change the (liveCD) root password. Edit /etc/shadow (the liveCD one) and copy the hash to the /etc/shadow on the system root for the real system. You've just changed the password, the old fashioned way.
The problem is I can't tell where the DVD filesystem and my computer's filesystem are delineated. I understand Linux filesystems in general, but this confuses me, because I've never had to do it or deal with it after a system was installed.

I am finding only my DVD's "/etc/shadow". So where is the computer's filesystem mounted when I boot into the DVD?

ak_random 07-14-2007 12:29 PM

Quote:

Originally Posted by ShellyCat
I am finding only my DVD's "/etc/shadow". So where is the computer's filesystem mounted when I boot into the DVD?

Once the DVD is booted, I'll assume you should looking at your desktop. Is there a hard drive icon for you to browse? If so, you should be able to find etc/shadow.

Otherwise, I'd open up a terminal shell, and manually mount your hard drive if it's not already mounted. You can then traverse the mount point to find /<mount_point>/etc/shadow to edit.

pixellany 07-14-2007 01:00 PM

When you boot from live CD, simply open a terminal and enter "fdisk -l". That will tell you where all your partitions are. You have to then figure out which one has the "/etc" directory. Once that is mounted, then go into /etc and find the "passwd" file. Edit this file to remove the "x" after the first ":". (Use whatever editor is installed--I use nano because its almost always there.) The edited file will look something like this:
root::0:0:root:/root:/bin/bash

save the file and reboot--you will now be able to login as root with no password.

One thing to be careful about: Suppose you have mounted the appropriate partition and "ls" shows that etc is there. To enter the etc directory, be sure not to do "cd /etc"--that would take you back to the /etc directory associated with your live linux). From the root level of the mounted partition, you would do "cd etc"

AceofSpades19 07-14-2007 01:00 PM

in KNOPPIX just go to /media and that is were your harddrive is

ShellyCat 07-14-2007 03:01 PM

The LinuxGazette solution worked [SOLVED]
 
http://linuxgazette.net/107/tomar.html

Thanks all. I couldn't do the solutions they suggested from the bootloader...every command I entered was interpreted as a boot image LILO thought I wanted it to look for.

As for the confusion about finding the proper /etc/shadow, that was because I was booting from my Slackware DVD. Need to use a "live" CD! (I did say I was tired. :o ) As for the "hda" vs. "sda" thing, well, I guess that's just the way it is -- the partition table uses "sda" to denote that the hard disk is SCSI, but apparently the live CD could care less. Using "hda2" worked just fine.

The instructions on LinuxGazette to mount and cd into the proper directory were perfect. My only complaint is the Knoppix Live CD doesn't have nano. :eek: VIM is very strange.

I deleted the hashed password, rebooted, logged in as root, and reset my password.


All times are GMT -5. The time now is 08:52 AM.