Tuesday, September 13, 2016

Transition from Ubuntu to FreeBSD - sh, csh, bash

FreeBSD 10.3 comes with sh and csh in the base distribution. In fact, root's default shell is csh whereas a normal user default shell is sh.

It is possible to install bash by
# pkg install -y bash

bash requires fdescfs(5) mounted on /dev/fd

If you have not done it yet, please do the following:

mount -t fdescfs fdesc /dev/fd

To make it permanent, you need the following lines in /etc/fstab:

fdesc /dev/fd fdescfs rw 0 0


Because bash, derived from Linux world, may utilize fdescfs, some bash scripts may not properly run on FreeBSD unless it is mounted as mentioned above. For this reason, I decided not to stick with bash on FreeBSD, as learning BSD as BSD, not Linux, is the whole purpose.

However, I immediately changed root's default shell as sh, as I csh is just too different from bash. For instance, one needs to use setenv in place of export in csh.

To change default shell to sh, run
# chsh -s /bin/sh
and change the default shell from /bin/csh to /bin/sh

Note: do not change root's default shell as anything other than those included in the base distribution. Read here for more details.

No comments:

Post a Comment