Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I just made a bit of a mistake:

  • Fresh install of FreeBSD 8.2
  • logged in as root
  • installed bash from ports
  • created users, setting bash as shell
  • vipw (edit passwd file)
  • changed root's shell from /bin/csh to /bin/bash
  • logged out
  • log in as root
  • WRONG!!

As you probably guessed, bash shell is not placed in /bin :( Pretty dumb mistake!

Now I can't login as root. I can login as my wheel user, but can't vipw.

Tried the following without luck:

  • Reboot to single user, /rescue/vi /etc/passwd
  • Login as wheel user, su -m

So how do i change the root shell back to /bin/csh ?

I could just re-install - but i'd rather learn some new stuff!

share|improve this question
up vote 9 down vote accepted

Boot into single user mode and then:

mount -w /

Change path to /usr/local/bin/bash

share|improve this answer
I have edited your answer, should be visible once it is peer reviewed; so SF tells me. Thank you very much, it helped me in the right direction followed by this article… – Phliplip Mar 31 '11 at 13:06

Use a live CD/DVD of some kind. (Gentoo is a good choice.) Just mount the drive, and edit the /etc/passwd file.

share|improve this answer
+1 for simple and effective fix – Sirex Mar 31 '11 at 12:42
Great tip, thank you for your help. Didn't use it this time, but could come in handy. – Phliplip Mar 31 '11 at 13:09
How is Gentoo a "good choice"?! The FreeBSD CD/DVD has an emergency shell, which can at least read the file system... – Chris S Sep 25 '12 at 14:04

Just a tip... After the first login as root, i change the toor password. This way, even with data corruption/disk or partition lost, I have a user with privileges and 2 différents shells.

share|improve this answer
I certainly will do that after this little mistake :) – Phliplip Mar 31 '11 at 13:09

Can you su (without -) ?

If not, maybe sudo -u root /usr/bin/bash could work?

Otherwise, boot from CD, mount the root file system, change the etc/passwd file on the root file system, sync, umount, reboot.

share|improve this answer
Can't su, can't sudo (not installed), can't install sudo – Phliplip Mar 31 '11 at 12:46

Try to modify grub boot string during boot so, that it couldn't find the kernel. grub will drop you to busybox. It has a built-in vi editor. Mount, edit and reboot.

share|improve this answer
No grub (hungry now) – Phliplip Mar 31 '11 at 13:11
-1 FreeBSD doesn't use Grub. – Chris S Sep 25 '12 at 14:04

The correct command for single user mode is:

mount -u -rw /
mount -a -t ufs

then just do: chsh -s /usr/local/bin/bash root

share|improve this answer
I have corrected the single user answer. Are you sure that the -r switch should be there? According to FreeBSD man mount this toggles read-only, and the w switch is read and write. A bit confusing. – Phliplip Mar 31 '11 at 13:16
Chris S: specifically, the mount -a -t ufs means, ONLY mount all file systems of type UFS, ie, don't mount nfs, ntfs, smb etc file systems. since these won't work in single user mode. – Allan Jude Sep 30 '12 at 20:21

I've just done exactly the same on a Synology Diskstation - I assumed /bin/bash was available when hurriedly changing the root shell. Doh.

I used the -s option of su when logged in as admin to force a shell:

-s, --shell=SHELL            run SHELL if /etc/shells allows it

That is:

su -s /bin/ash 


share|improve this answer
This only works if you can login as a user in the Wheel group. The Question didn't have such a user. Your case really isn't the same... – Chris S Oct 8 '12 at 1:07
OP says: "...I can login as my wheel user..." – Andy Triggs Oct 9 '12 at 9:46

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.