LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   issue with 'su ' login (https://www.linuxquestions.org/questions/linux-newbie-8/issue-with-su-login-808035/)

avee137 05-15-2010 01:14 PM

issue with 'su ' login
 
Code:

[avi@localhost ~]$ cat /etc/passwd
root:x:0:0:root:/root:/bin/bash:/sbin
bin:x:1:1:bin:/bin:/sbin/nologin

I made following change to the /etc/passwd file.I added /sbin with a hope to avoid setting PATH every time i need a command from /sbin but i ended up with following:
Code:

[avi@localhost ~]$ su
Password:
su: /bin/bash:/sbin: No such file or directory

i cannot delete that entry from /etc/passwd as i cannot login as root.

please help!

EricTRA 05-15-2010 01:18 PM

Hello,

Why would you do that? The /bin/bash in the passwd file is just the shell that's been assigned to root and has nothing to do with your PATH environment. Remove it from the passwd file and you'll not have the error any more. If you want to know what's in your path variable then echo it:
Code:

echo $PATH
Kind regards,

Eric

EricTRA 05-15-2010 01:21 PM

Hi,

Also check your /var/backups (if that exists), I seem to remember that Debian makes backups of passwd and shadow to that directory. Not sure if it's the same for your distro (CentOS wasn't it?).

Kind regards,

Eric

avee137 05-15-2010 01:36 PM

Quote:

Originally Posted by EricTRA (Post 3969808)
Hi,

Also check your /var/backups (if that exists), I seem to remember that Debian makes backups of passwd and shadow to that directory. Not sure if it's the same for your distro (CentOS wasn't it?).

Kind regards,

Eric

there is no place like /var/backups here.
Any other way??

Awatto 05-15-2010 02:00 PM

Try su with the --shell argument.

Code:

su --shell=/bin/bash
From there, edit that file back to the original. To change your shell please use chsh from now on.

If you'd like to change your path, look at .bash_profile

avee137 05-15-2010 02:04 PM

Quote:

Originally Posted by Awatto (Post 3969854)
Try su with the --shell argument.

Code:

su --shell=/bin/bash
From there, edit that file back to the original. To change your shell please use chsh from now on.

If you'd like to change your path, look at .bash_profile

Code:

[avi@localhost ~]$ su --shell=/bin/bash
Password:
su: using restricted shell /bin/bash:/sbin
su: /bin/bash:/sbin: No such file or directory

is what i get.No change!

Awatto 05-15-2010 02:07 PM

err, try it without the equals, sorry.

Code:

su --shell /bin/bash
hope that works

avee137 05-15-2010 02:12 PM

Quote:

Originally Posted by Awatto (Post 3969866)
err, try it without the equals, sorry.

Code:

su --shell /bin/bash
hope that works

nay...same result!

EricTRA 05-15-2010 02:21 PM

Hi,

Try as the user you're logged in with:
Code:

sudo vi /etc/passwd
and see if that give you a result. When it asks for a password, you have to provide your user password, not the root one.

Kind regards,

Eric

avee137 05-15-2010 02:30 PM

Quote:

Originally Posted by EricTRA (Post 3969883)
Hi,

Try as the user you're logged in with:
Code:

sudo vi /etc/passwd
and see if that give you a result. When it asks for a password, you have to provide your user password, not the root one.

Kind regards,

Eric

Code:

[avi@localhost ~]$ sudo vi  /etc/passwd
Password:
avi is not in the sudoers file.  This incident will be reported.

i cant edit the sudoers file without root access.i am in kinda "catch your own tail situation" :(

EricTRA 05-15-2010 02:34 PM

Quote:

Originally Posted by avee137 (Post 3969893)
i cant edit the sudoers file without root access.i am in kinda "catch your own tail situation" :(

Hello,

That's what happens when you put stuff in places where it doesn't belong. I'm sure you've learned a lesson here, first study, learn, investigate before trying out stuff.

Kind regards,

Eric

avee137 05-15-2010 02:48 PM

Quote:

Originally Posted by EricTRA (Post 3969896)
Hello,

That's what happens when you put stuff in places where it doesn't belong. I'm sure you've learned a lesson here, first study, learn, investigate before trying out stuff.

Kind regards,

Eric

i fixed that with some help.thanks for suggestion.
I did that by booting in single user mode and using nano to edit the /etc/passwd file. It worked fine.


All times are GMT -5. The time now is 10:27 PM.