Installing the BASH Shell on FreeBSD

By default, FreeBSD does not come with the bash shell pre-installed like on most Linux distributions. To install it, run the following commands:

pkg install bash
mount -t fdescfs fdesc /dev/fd
echo "fdesc    /dev/fd        fdescfs        rw    0    0" >> /etc/fstab

You can also change the default shell to bash but before you do, remember to log out of root.

Note: Do not change the default shell of the root user.

To change the default shell to bash, run the following command:

chsh -s /usr/local/bin/bash

You will have to log out and then log back in for the changes to take effect.

To customize the shell further, create the .Xdefaults in your home directory with the following lines:

xterm*Background:    black
xterm*Foreground:    white

and create a .bashrc file also in your home directory with the following line:

alias ls='ls -G'

which invokes a color display when using the ls command. In order for FreeBSD to see this .bashrc file, you will need to create a .bash_profile file, also in your home directory, with the following line:

source ~/.bashrc

Sources:
1. http://www.cyberciti.biz/faq/freebsd-bash-installation/
2. https://www.digitalocean.com/community/tutorials/how-to-get-started-with-freebsd-10-1
3. http://bash.cyberciti.biz/guide/Create_and_use_aliases
4. https://gist.github.com/igniteflow/4284590
5. http://www.linuxquestions.org/questions/debian-26/how-to-change-background-and-fonts-color-in-xterm-156290/
6. http://www.cyberciti.biz/tips/freebsd-how-to-enable-colorized-ls-output.html
7. https://forums.freebsd.org/threads/cant-get-bash-alias-to-stick.54570/

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License