LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-14-2007, 03:18 AM   #1
ShellyCat
Member
 
Registered: Jul 2007
Distribution: Slackware 13
Posts: 178

Rep: Reputation: 29
Question 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?
 
Old 07-14-2007, 03:20 AM   #2
AceofSpades19
Senior Member
 
Registered: Feb 2007
Location: Chilliwack,BC.Canada
Distribution: Slackware64 -current
Posts: 2,079

Rep: Reputation: 58
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
 
Old 07-14-2007, 03:51 AM   #3
ShellyCat
Member
 
Registered: Jul 2007
Distribution: Slackware 13
Posts: 178

Original Poster
Rep: Reputation: 29
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.
 
Old 07-14-2007, 03:58 AM   #4
ShellyCat
Member
 
Registered: Jul 2007
Distribution: Slackware 13
Posts: 178

Original Poster
Rep: Reputation: 29
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.
 
Old 07-14-2007, 04:04 AM   #5
ShellyCat
Member
 
Registered: Jul 2007
Distribution: Slackware 13
Posts: 178

Original Poster
Rep: Reputation: 29
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?

Last edited by ShellyCat; 07-14-2007 at 04:16 AM.
 
Old 07-14-2007, 10:40 AM   #6
Junior Hacker
Senior Member
 
Registered: Jan 2005
Location: North America
Distribution: Debian testing Mandriva Ubuntu
Posts: 2,687

Rep: Reputation: 61
Not sure if this thread will have an answer, but worth looking at:
http://www.linuxquestions.org/questi...d.php?t=535701
 
Old 07-14-2007, 12:01 PM   #7
ShellyCat
Member
 
Registered: Jul 2007
Distribution: Slackware 13
Posts: 178

Original Poster
Rep: Reputation: 29
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?
 
Old 07-14-2007, 12:29 PM   #8
ak_random
Member
 
Registered: Jun 2007
Location: Silicon Valley, CA
Distribution: Xubuntu
Posts: 83

Rep: Reputation: 15
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.
 
Old 07-14-2007, 01:00 PM   #9
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
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"
 
Old 07-14-2007, 01:00 PM   #10
AceofSpades19
Senior Member
 
Registered: Feb 2007
Location: Chilliwack,BC.Canada
Distribution: Slackware64 -current
Posts: 2,079

Rep: Reputation: 58
in KNOPPIX just go to /media and that is were your harddrive is
 
Old 07-14-2007, 03:01 PM   #11
ShellyCat
Member
 
Registered: Jul 2007
Distribution: Slackware 13
Posts: 178

Original Poster
Rep: Reputation: 29
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. ) 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. VIM is very strange.

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


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
root password doesn't work at log in, works using "su" etfd Red Hat 3 01-10-2007 06:38 AM
squirrelmail -> "change password" option is missing cccc Linux - General 1 09-26-2006 03:43 AM
Root password no good for "software security device?" Rusted Linux - Security 3 04-26-2006 05:00 AM
where is the "enter root password or Contrl-D to continue" after FS repair at boot jg167 Red Hat 0 11-17-2004 01:20 AM
Change text of "password will expire in..." Schlabbl Linux - Software 0 08-25-2004 03:48 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:04 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration