3

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!

tombull89
  • 2,964
  • 8
  • 41
  • 52
Phliplip
  • 541
  • 8
  • 22

7 Answers7

9

Boot into single user mode and then:

mount -w /
vipw

Change path to /usr/local/bin/bash

exit
Chris S
  • 77,945
  • 11
  • 124
  • 216
pconcepcion
  • 334
  • 6
  • 16
  • 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 http://www.cyberciti.biz/tips/howto-freebsd-reset-recover-root-password.html – Phliplip Mar 31 '11 at 13:06
3

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.

thc2cat
  • 31
  • 2
2

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

David Krider
  • 164
  • 9
2

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.

MattBianco
  • 597
  • 1
  • 7
  • 23
0

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

Allan Jude
  • 1,286
  • 9
  • 13
  • 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
0

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.

Andy Triggs
  • 109
  • 3
-1

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.

HUB
  • 6,630
  • 3
  • 23
  • 22