Changing root's shell

Jerry McAllister jerrymc at
Wed Aug 9 15:10:40 UTC 2006

> On 8/8/06, Pete Slagle <freebsd-questions at> wrote:
> >
> > Ross Penner wrote:
> >
> > > how do you drop to single user mode? I just know how to get there at
> > > boot time.
> > >
> > > Thanks.
> > >
> > > On 8/8/06, *Pete Slagle* < freebsd-questions at
> > > <mailto:freebsd-questions at>> wrote:
> > >
> > >     ross wrote:
> > >
> > >     > so it seems changed root login's shell to /usr/bin/bash which
> > doesn't
> > >     > exist. now I can't login to root at all. Oh yes, sudo isn't
> > >     installed. How
> > >     > would you grand masters of FreeBSD fix my embarrasing mistake.
> > >
> > >     Dunno if any grand masters are about, but maybe I can help with this
> >
> > >     one.
> > >
> > >       - drop to single user mode: `shutdown now`
> > >       - when prompted for a shell, type /bin/sh
> > >       - `vipw /etc/passwd` and (carefully) change root's shell to
> > /bin/sh
> > >       - type `exit` at the shell prompt to return from single user mode
> >
> > Normally you just do what I said, `shutdown now` as root, but I guess
> > you can't do that in your situation. (Silly me.) So just reboot into
> > single user mode instead, and follow the rest of the steps.
> >
> > Good luck,
> > Pete
> >
> > interestingly, by hitting the power button on the front, it went through
> the shutdown process without root permissions.
> I followed your steps but the problem remains. The /etc/passwd file is
> edited but I still can't logon as root. When I changed the shell initially,
> I used chpass. I
> also tried changeing the /etc/master.passwd file to no avail.

You need to make sure that the root file system is remounted with
read/write permission.   To do that, simply type
  mount -u /

Rather than trying to edit either /etc/passwd or /etc/master.passwd 
directly, you should use vipw to change things in the password systen
and for that you need /usr mounted if it is in a separate file system 
from root.   So, just to be sure everything you need is available type:

  mount -a

Then type:


and edit the root entry and put the shell back to /bin/sh
Always leave the root shell as /bin/sh

If you want to do work as root with some different shell, create
another root account such as Rwork or Wroot or whatever and
give that the other shell and use it.   That leaves root pristine
for those times of difficulty.

To create another root account, just use vipw and dupicate the line
for root and edit the new copy to have a new name and the different
shell.    You might also want to give it its own home directory to
keep things nice and clean - say /root/Rwork if the id you made is Rwork.

Get out of vipw as you would vi - eg with 'ESC :wqENTER' and then the
account is made and all the master.passwd and database are updated
correctly, automatically and with appropriate file locking.  

Then you need to set a password on the new account.
When you do this, you MUST use the id name on the passwd command.
Other wise it will change the first id that has the same UID which
will most likely be the regular root account rather than your new one.
So, type:

  passwd Rwork     (presuming you made the new id be named Rwork)

answer the double prompts and voila, it is there.

If you made it have its own home directory, you have to create 
that directory so type:

  cd /root
  mkdir Rwork         (or whatever new root id you created)

Put whatever .cshrc .login .profile you want in to that directory
and you are home free.

NOTE that if your system does not allow remote root logins so
     you have to log in as a normal ID and then su to root, then
     the same will be true for this new account.  Log in as a
     normal (non-root) id and then do:  su Rwork     (if Rwork is
     that new root ID).   The regular account will also still need
     to be in the wheel group to do the su to any root ID.

Have fun,


> _______________________________________________
> freebsd-questions at mailing list
> To unsubscribe, send any mail to "freebsd-questions-unsubscribe at"

More information about the freebsd-questions mailing list