Solved Having trouble changing $SHELL with chsh

I have used chsh -s /usr/local/bin/bash to change the default shell for my user from /bin/sh. bash is available in /etc/shells and the shell has been correctly updated for my user in /etc/passwd.
Code:
$ grep bash /etc/passwd
fl121:*:1000:1000:FreeBSD 12.1 User (Intel):/home/fl121:/usr/local/bin/bash
When I went to make this thread I realised that I accidentally ran sudo chsh -s /usr/local/bin/bash and changed root's shell to bash... I just changed that back... I'm not sure if that would have caused any problems as sh is a subset of bash.
I have rebooted several times but $SHELL has not changed and xterm and urxvt start into sh. It's possible that I've done something foolish in a configuration file a year or more ago and forgotten about it... I am getting better, I just started reading Absolute FreeBSD today, I am up to the section on compiling kernels. It has inspired me to read the handbook back to back also.
An issue that cropped up in my googling was that sometimes the shell would not change if people were logged in from other machines... they would check this with the who command. This is my output:
Code:
$ w
4:46PM  up 33 mins, 4 users, load averages: 0.82, 1.19, 1.18
USER       TTY      FROM    LOGIN@  IDLE WHAT
fl121      v0       -       4:13PM    32 xinit /home/fl121/.xinitrc -- /usr/local/bin/X :0 -auth /home/fl121/.serverauth.11959
fl121      pts/0    :0      4:13PM    32 bash
fl121      pts/42   :0      4:13PM    32 sh
fl121      pts/41   :0      4:13PM    32 conky
This was after logging into X which I do by typing "startx". $SHELL is /bin/sh immediately after I log in also.

Thanks for any help.

Edit: Not sure if this is useful at all but I just enabled sshd and ssh'd to my FreeBSD box, still /bin/sh.

Edit2: Ok I solved it. Instead of running chsh -s /usr/local/bin/bash as fl121 I tried switching to root and running chsh -s /usr/local/bin/bash fl121 and it returned:
Code:
chsh: entry inconsistent
chsh: pw_copy: Invalid argument
Followed the errors and found https://forums.freebsd.org/threads/chsh-not-working.72695/
Running pwd_mkdb -C /etc/passwd gives

Code:
pwd_mkdb: corrupted entry
pwd_mkdb: at line #3
pwd_mkdb: /etc/passwd: Inappropriate file type or format
sudo vipw
---
Then make a trivial change, like adding a space to a comment in line 1 or 2, and "wq!"
Your password files should all be re-generated.

Logged out and back in and everything's good 👍
I also realised that root's original shell was /bin/csh not /bin/sh.
 
Check your system with freebsd-update IDS. If any binaries differ from the known checksums, you'll have to repair or reinstall. Obviously the configurations files that you changed (or were changed by the system) will differ in their checksum. Also do pkg check --checksums --all.
 
Curiously I have mismatches for fsck related programs, I noticed this yesterday and thought maybe it was to do with updating to 12.2.
Code:
$ sudo pkg check --checksums --all
Password:
Checking all packages:  10%
e2fsprogs-1.45.7: checksum mismatch for /usr/local/sbin/e2fsck
e2fsprogs-1.45.7: checksum mismatch for /usr/local/sbin/fsck.ext2
e2fsprogs-1.45.7: checksum mismatch for /usr/local/sbin/fsck.ext3
e2fsprogs-1.45.7: checksum mismatch for /usr/local/sbin/fsck.ext4
e2fsprogs-1.45.7: checksum mismatch for /usr/local/sbin/fsck_ext2fs
Checking all packages: 100%
I suppose I might as well reinstall them. The output of the other command seems fine, only config files that I or the system changed.

Edit: Apparently it's a known bug https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=252184
 
Back
Top