Can't login as root after changing the shell to bash

Jerry McAllister jerrymc at msu.edu
Tue Oct 14 12:22:45 PDT 2008


On Tue, Oct 14, 2008 at 08:28:13PM +0200, Aniruddha wrote:

> I tried to change the root's shell to bash. I used this command: 'chsh
> -s /usr/local/bin/bash'. Prior to changing the shell for root I did it
> for my user account using the same command without problems.
> Unfortunately after a reboot I can't login as root anymore because my
> system can't find /usr/local/bin/bash. How can I fix this? I tried
> booting the freesbie cd but this wouldn't boot :(. Thanks in  advance!

Sounds like /usr/local/bin is either not in the path for root or
that the /usr or /usr/local file system is not mounted - which would
be true in a single user boot.

You should never change root's shell.   It is doable if you move
some files around, but it is too likely that you will come up with
a situation like this where the alternate shell is not available.

You can try coming up in 'single user' mode.
Older systems required you to hit the space bar within the countdown.
Newer ones require you to select the right option from a menu.  I think
it is '4' but don't want to reboot at the minute to check.

It will ask you which shell you want.   Just take the default (eg hit ENTER).
Then remount /   by doing:    
  mount -u /
Then edit /etc/passwd using the vipw(8) utility - just type: 
  vipw
It is just like using vi.
Change your shell back to /bin/csh  
The shell is the last field in the line for the root account.
Then, either reboot or just exit the single user mode and come
up in full boot.

If you absolutely must degenerate to using bash on a root account,
create another root acount.    Just go in to vipw and copy the 
root account line and replace the fields needed - namely the id,
the name stuff, the login directory and the shell field.
Of course, do not change the original root line. 

Suggestion, for example, if your usual account might be clyde,
then make a root account called Rclyde.   Make a home directory
of /root/Rclyde.    Don't forget to go and create that directory.

It you can live without making that alternate root account, it is
better to log in with your non-root account and then  su(1) to
get to root.    Don't forget to add your non-root account to
the 'wheel' group.   Edit the  /etc/group  file.   This is safer
than logging in over the net directly to a root account because
you can make sure your transmissions are encripted before going
in to root.

////jerry



> -- 
> Regards,
> 
> Aniruddha
> _______________________________________________
> freebsd-questions at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "freebsd-questions-unsubscribe at freebsd.org"


More information about the freebsd-questions mailing list