LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 05-27-2007, 10:23 PM   #1
karen.pertierra
LQ Newbie
 
Registered: Jan 2007
Posts: 20

Rep: Reputation: 0
Unhappy accidentally commented root user at /etc/passwd


Hello everyone,

I need help on this asap.

I accidentally commented the root user at /etc/passwd.

#root:x:0:0:root:/root:/bin/bash

thus, I cannot su - using SSH. It gives me the error:

su: user root does not exist

Can anybody help me on this?

Thanks in advace.

Karen
 
Old 05-27-2007, 10:31 PM   #2
jtshaw
Senior Member
 
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Blog Entries: 1

Rep: Reputation: 67
Your going to want to boot your machine on a live cd like knoppix, mount the drive, and uncomment out the root user. Then reboot without the CD and you should be just fine.... If you need any more in depth instructions let me know.
 
Old 05-27-2007, 10:37 PM   #3
karen.pertierra
LQ Newbie
 
Registered: Jan 2007
Posts: 20

Original Poster
Rep: Reputation: 0
Thanks so much for that very quick reply.

Im a total Linux newbie, and yes I need a more detailed procedure.

1. Where can I download knoppix?
2. When you say mount the drive, how will I do that?

Cheers!
 
Old 05-27-2007, 11:07 PM   #4
jtshaw
Senior Member
 
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Blog Entries: 1

Rep: Reputation: 67
You can get Knoppix here.

I believe it will automatically mount your HD's in the /mnt or /media directory when it boots... but if not let me know and I'll attempt to walk you through it...
 
Old 05-27-2007, 11:22 PM   #5
karen.pertierra
LQ Newbie
 
Registered: Jan 2007
Posts: 20

Original Poster
Rep: Reputation: 0
Thanks for the download link.

If I do the mount, will if affect any settings or files in the server? Will I not lose any information? When I do df-h, here is what I get.

Filesystem Size Used Avail Use% Mounted on
/dev/hda1 4.9G 206M 4.4G 5% /
none 121M 0 121M 0% /dev/shm
/dev/hda6 7.9G 786M 6.8G 11% /home
/dev/hda3 9.7G 1.5G 7.8G 16% /usr
/dev/hda2 9.7G 5.3G 4.0G 58% /var
 
Old 05-28-2007, 06:16 AM   #6
dawkcid
Member
 
Registered: May 2007
Location: UK
Distribution: LFS,Slackware,Slamd64,NetBSD
Posts: 102

Rep: Reputation: 15
You don't need a live cd. Just:

Append 'init=/bin/sh' to the boot command line.
remount / rw (mount -o remount,rw /)
edit /etc/passwd
remount ro (mount -o remount,ro /)
exec /sbin/init to continue booting normally (you don't need to reboot).
 
Old 05-28-2007, 08:05 AM   #7
jtshaw
Senior Member
 
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Blog Entries: 1

Rep: Reputation: 67
Quote:
Originally Posted by dawkcid
You don't need a live cd. Just:

Append 'init=/bin/sh' to the boot command line.
remount / rw (mount -o remount,rw /)
edit /etc/passwd
remount ro (mount -o remount,ro /)
exec /sbin/init to continue booting normally (you don't need to reboot).
You know... that probably is easier...

You can probably also append 'single' to the kernel parameters on bootup and get in that way.
 
Old 05-28-2007, 08:07 AM   #8
jtshaw
Senior Member
 
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Blog Entries: 1

Rep: Reputation: 67
Quote:
Originally Posted by karen.pertierra
Thanks for the download link.

If I do the mount, will if affect any settings or files in the server? Will I not lose any information? When I do df-h, here is what I get.

Filesystem Size Used Avail Use% Mounted on
/dev/hda1 4.9G 206M 4.4G 5% /
none 121M 0 121M 0% /dev/shm
/dev/hda6 7.9G 786M 6.8G 11% /home
/dev/hda3 9.7G 1.5G 7.8G 16% /usr
/dev/hda2 9.7G 5.3G 4.0G 58% /var
You might want to consider the above two posts as alternatives... but no, you won't lose any information.

If you were to do have to do the mount yourself through knoppix open up a terminal and do the following

mkdir /mnt/hda1
sudo mount /dev/hda1 /mnt/hda1
edit /mnt/hda1/etc/passwd
reboot
 
Old 05-29-2007, 12:17 AM   #9
karen.pertierra
LQ Newbie
 
Registered: Jan 2007
Posts: 20

Original Poster
Rep: Reputation: 0
Originally Posted by dawkcid
You don't need a live cd. Just:

Append 'init=/bin/sh' to the boot command line.
remount / rw (mount -o remount,rw /)
edit /etc/passwd
remount ro (mount -o remount,ro /)
exec /sbin/init to continue booting normally (you don't need to reboot).


Hi dawkcid,

Im using SSH. When I typed, init-/bin/sh, in the "Login as" prompt, it asked for a password. I typed the password for root, but did not accept it.

login as: init=/bin/sh
init=/bin/sh@202.91.163.28's password:
Access denied

Any ideas? Or I should type directly to the actual server's prompt and not thru SSH?

Thank for your help.
 
Old 05-29-2007, 12:29 AM   #10
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Do you have physical access to the computer?

The init=/bin/bash is a kernel boot option and not an ssh login name.
 
Old 05-29-2007, 01:14 AM   #11
karen.pertierra
LQ Newbie
 
Registered: Jan 2007
Posts: 20

Original Poster
Rep: Reputation: 0
Yes, I also have physical access to the server.

Can you walk me through the process?

Sorry, Im a total linux newbie and not so familiar with that kernel boot thing.
 
Old 05-29-2007, 08:28 AM   #12
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Enter init=/bin/bash in the boot menu's kernel options.

Then run an editor such as vim and edit out the comment character.

You can also use sed to delete the "#" character on the line containing root:
sed -i '/root/s/#root/root/' /etc/passwd
 
Old 05-29-2007, 10:53 PM   #13
karen.pertierra
LQ Newbie
 
Registered: Jan 2007
Posts: 20

Original Poster
Rep: Reputation: 0
when i typed: init=/bin/sh to the boot command line, It says :

the kernel parameter does not exist.
Even when I use/type 'single', it gives the same kernel error.

Any ideas?
 
Old 05-29-2007, 11:01 PM   #14
karen.pertierra
LQ Newbie
 
Registered: Jan 2007
Posts: 20

Original Poster
Rep: Reputation: 0
oh sorry about that, the error said:

Could not find kernel image: init=/bin/sh

or if i type 'single'

Could not find kernel image: single

Any ideas?
 
Old 05-30-2007, 01:14 AM   #15
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Add "init=/bin/bash" to the end of what is there. If that doesn't work or there isn't anything on the line try "linux init=/bin/bash".
The single option might work, but I think you may need the a root password, which won't work in your case.

Another option is to boot up with a rescue disk, mount the root partition and edit out the "#" character you added. Then save the file and reboot.
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
alias for user to gain root tty with no passwd officecase Linux - General 2 05-11-2007 11:05 AM
help, accidentally deleted /root directory ahimsel08 Linux - Software 6 07-01-2004 02:02 AM
/etc/securetty --> I commented out all lines and I can still log in as root adamrau Linux - Security 2 05-30-2004 06:16 AM
accidentally rm -fr in root (/) directory Under Fire Linux - Newbie 2 11-15-2003 10:03 PM
root login incorrect ,then passwd root,but error sunnycn Linux - Security 6 05-20-2002 10:54 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 05:14 AM.

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