LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 04-09-2008, 07:50 AM   #1
elthox
Member
 
Registered: Oct 2006
Posts: 41

Rep: Reputation: 15
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
 
Old 04-09-2008, 08:31 AM   #2
eltnux
LQ Newbie
 
Registered: Nov 2007
Posts: 4

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

Elton
 
Old 04-09-2008, 08:33 AM   #3
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
There may be a simpler way, but I'd boot a live cd, mount the relvant volume and edit it that way
 
Old 04-09-2008, 08:41 AM   #4
elthox
Member
 
Registered: Oct 2006
Posts: 41

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by billymayday View Post
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?
 
Old 04-09-2008, 08:48 AM   #5
blacky_5251
Member
 
Registered: Oct 2004
Location: Adelaide Hills, South Australia
Distribution: RHEL 5&6 CentOS 5, 6 & 7
Posts: 572

Rep: Reputation: 56
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.
 
Old 04-09-2008, 09:00 AM   #6
dopefish
Member
 
Registered: Nov 2003
Location: Northcliffe, WA
Distribution: Slackware 12.0
Posts: 481

Rep: Reputation: 30
try booting single user and editing the file
when you come to grub boot screen type e then type init=/bin/bash
then enter
 
Old 04-09-2008, 10:20 AM   #7
elthox
Member
 
Registered: Oct 2006
Posts: 41

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by dopefish View Post
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.
 
Old 04-09-2008, 04:49 PM   #8
marquardl
Member
 
Registered: Apr 2008
Posts: 100

Rep: Reputation: 15
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

Last edited by marquardl; 05-01-2008 at 04:45 AM.
 
Old 04-09-2008, 07:51 PM   #9
dopefish
Member
 
Registered: Nov 2003
Location: Northcliffe, WA
Distribution: Slackware 12.0
Posts: 481

Rep: Reputation: 30
No worries, glad to help
 
Old 04-10-2008, 02:31 AM   #10
elthox
Member
 
Registered: Oct 2006
Posts: 41

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by marquardl View Post
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Elementary Question - Can't Edit File - Need Root rrrssssss Linux - Newbie 2 04-12-2005 04:05 AM
Can't edit /etc/X11/XF86Config file in ANY editor under root! please help Fear58 Mandriva 6 12-12-2004 02:19 AM
how to edit a file without logging in as root? osat3ch Fedora 3 08-22-2004 12:16 AM
$#!% passwd file removed, how do I log in as root? BrianK Linux - General 6 08-19-2004 03:23 PM
Bash script to edit passwd without Root password? NetFlash Linux - Newbie 2 11-29-2003 05:22 PM


All times are GMT -5. The time now is 11:26 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration