LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to edit the /etc/passwd file not using root? (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-edit-the-etc-passwd-file-not-using-root-634151/)

elthox 04-09-2008 06:50 AM

How to edit the /etc/passwd file not using root?
 
Hi All,

Today I faced a problem trying to log in as root. The output error is
cannot execute sh: No such file....

I doubted there is something wrong with shell interpreter which resides in /etc/passwd file for every user who logs in.
I checked and the line for root account was self-corrupted like below:
root:x:0:0:root:/root:sh

THe line for the user I`m using looks fine

elton:x:1000:1000:Elton,,,:/home/elton:/bin/bash

Can anyone tell me how to modify the line of root to add the proper path of shell?

Thanks

eltnux 04-09-2008 07:31 AM

Sorry can't help with your problem, just wanted to say hello to a fellow Elton (Don't see many of us around)

Elton

billymayday 04-09-2008 07:33 AM

There may be a simpler way, but I'd boot a live cd, mount the relvant volume and edit it that way

elthox 04-09-2008 07:41 AM

Quote:

Originally Posted by billymayday (Post 3115694)
There may be a simpler way, but I'd boot a live cd, mount the relvant volume and edit it that way

Even if the debian i`m using is under virtual machine, boo from cd is valid way?

blacky_5251 04-09-2008 07:48 AM

You could log in as a normal user and use "su" or "sudo" to edit the /etc/passwd file.
Code:

su -c "vi /etc/passwd"
Password:

In this example I'm using "su", so you enter the root user's password.
Code:

sudo vi /etc/passwd
Password:

In the second example I'm using "sudo", so you enter the "normal" user's password, not root's.

dopefish 04-09-2008 08:00 AM

try booting single user and editing the file
when you come to grub boot screen type e then type init=/bin/bash
then enter

elthox 04-09-2008 09:20 AM

Quote:

Originally Posted by dopefish (Post 3115724)
try booting single user and editing the file
when you come to grub boot screen type e then type init=/bin/bash
then enter

Thanks, I managed to edit passwd file and now I can log in.

marquardl 04-09-2008 03:49 PM

curious
 
I'm just curious:
how can the /etc/password file get self-corrupted?
And even so only by having the shell definition changed?

You surely must have done something to it...

Xen in Hardy

dopefish 04-09-2008 06:51 PM

No worries, glad to help

elthox 04-10-2008 01:31 AM

Quote:

Originally Posted by marquardl (Post 3116163)
I'm just curious:
how can the /etc/password file get self-corrupted?
And even so only by having the shell definition changed?

You surely must have done something to it...

Bye,
M

Hi Marquard,

Just for your curiosity I`m not that stupid to change my self the passwd file and specifically the line belonging to the root :) I don`t know what happened, as far as i remember before yesterday nothing critical was installed in the system...so it will be a mystery :)

Thanks


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