Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
add comment

7 Answers 7

up vote 8 down vote accepted

Boot into single user mode and then:

mount -w /
vipw

Change path to /usr/local/bin/bash

exit
share|improve this answer
1  
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 cyberciti.biz/tips/… –  Phliplip Mar 31 '11 at 13:06
add comment

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
add comment

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
add comment

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
add comment

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
add comment

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
add comment

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 

Phew.

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
add comment

Your Answer

 
discard

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.