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 - Distributions > Debian
User Name
Password
Debian This forum is for the discussion of Debian Linux.

Notices


Reply
  Search this Thread
Old 11-09-2011, 11:52 AM   #1
acetonitrile
Member
 
Registered: Aug 2009
Location: NYC
Distribution: Debian
Posts: 32

Rep: Reputation: 15
[Problem Solved] Accidentally changed root user to nonexistent shell and more and more


When I tried to install a software I got some error message like below.

# source cns_solve_env
bash: setenv: command not found
bash: setenv: command not found
bash: cns_solve_env: line 32: syntax error near unexpected token `setenv'
bash: cns_solve_env: line 32: ` if ( ! $?CNS_ARCH ) setenv CNS_ARCH `$CNS_SOLVE/bin/getarch`'


Depend on google result I feel it is the shell problem and want to switch shell to sch. What I did is like this:

# cat /etc/shells
# /etc/shells: valid login shells
/bin/csh
/bin/sh
/usr/bin/es
/usr/bin/ksh
/bin/ksh
/usr/bin/rc
/usr/bin/tcsh
/bin/tcsh
/usr/bin/esh
/bin/dash
/bin/bash
/bin/rbash

# chsh
Changing the login shell for root
Enter the new value, or press ENTER for the default
Login Shell [/bin/bash]: csh
chsh: Warning: csh does not exist


Nightmare came from then on.

First I tried to redo "chsh", and I have been asked to input password, but even with the right password, I got this information.
chsh: PAM authentication failed

Even worse, I tried to modified /etd/passwd by gedit from

root:x:0:0:root:/root:csh

to

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

But anything changed and suddenly gedit does not working anymore. Until now I still get into the terminal with superuser without password, I do not understand why.

So I began to use vi to edit it back, now I got the message fail to open the terminal.

Really need help in this case.

Last edited by acetonitrile; 11-09-2011 at 02:00 PM. Reason: Problem solved
 
Old 11-09-2011, 01:14 PM   #2
kbscores
Member
 
Registered: Oct 2011
Location: USA
Distribution: Red Hat
Posts: 259
Blog Entries: 9

Rep: Reputation: 32
It doesn't know where your home directory is nor does it know any pathes because it doesn't know where your home is.

Use following:

Code:
/bin/bash
this will put you into bash shell

Next set a temporary path variable:

Code:
export PATH=/bin
This should give you access to all, if not all then most of your commands again.

Code:
vi /etc/passwd
And replace root line with:

Code:
root:x:0:0:root:/root:/bin/bash
Save file then - Restart

if you want to change to c-shell user this instead to change shell - if something is misconfigured it will not let you change it.

Code:
usermod -s /bin/csh root




This should work for a Debian box.

Last edited by kbscores; 11-09-2011 at 01:17 PM.
 
1 members found this post helpful.
Old 11-09-2011, 02:09 PM   #3
acetonitrile
Member
 
Registered: Aug 2009
Location: NYC
Distribution: Debian
Posts: 32

Original Poster
Rep: Reputation: 15
More questions

Thanks a lot kbscores. But I do have some questions here.

I fixed the problem. During the waiting, by any chance I remembered, I used the command /bin/bash, and after that I noticed that I can use the root terminal again without been asked the password. And also, I can use gedit again.

So I just followed what you told how to change the /etc/passwd as you post.

Than I restart.

The first question is I tried to login with root, but with the password I used to have for root, I can not log into the X windows, but I can active the root terminal with that? Does it normal? And also, how did debian remember the previous password, and what make it change back?

Second I am not dare to try the command chsh again to see if I still have the "chsh: PAM authentication failed" problem. Do you think I can try that?

Thanks for your time again.

And looks like "usermod -s /bin/csh root" does not work here to change the shell mode.
It works, just need to open another root terminal.

Last edited by acetonitrile; 11-09-2011 at 02:20 PM.
 
Old 11-09-2011, 02:55 PM   #4
kbscores
Member
 
Registered: Oct 2011
Location: USA
Distribution: Red Hat
Posts: 259
Blog Entries: 9

Rep: Reputation: 32
If you are able to login without a password most likely root password isn't enforced for all runlevels. Specifically runlevel 1. It isn't super secure to leave it open, but a lot of organizations leave it open for runlevel 1 because there is no network access , no GUI and only a single user may log into box. This provides admins a back door for getting into a box incase they cannot remember password.


As for PAM error, most likely pam is being used to authenticate and it doesn't have a login shell set.

All chsh does is it will change login shell - It would be similar to using usermod

to change to bash shell use:
Code:
chsh -s /bin/bash root

If you want to see path or shells available use:

Code:
chsh -l
Finally to get back to a gui you need to switch run levels try:

Code:
init 5
If there is more wrong then it might generate some errors if so just post them.
 
1 members found this post helpful.
  


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
[SOLVED] Accidentally changed ownership of a port from root to user Handtuch Linux - Security 2 08-20-2011 10:03 AM
changed shell using 'chsh'! Now cant login to root !! ?? Help ashikaumanga Linux - General 3 01-22-2009 11:07 PM
SUSE - Root Shell accidentally set to /bin/false LinuxBaby Linux - Server 7 02-21-2008 09:50 AM
accidentally commented root user at /etc/passwd karen.pertierra Linux - General 15 05-30-2007 10:21 PM
changed root's shell accidentally frankie_DJ Linux - Newbie 7 09-19-2004 11:28 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian

All times are GMT -5. The time now is 02: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