BASH and FreeBSD

By default, many Linux distro’s have a nice BASH prompt. If you’ve just installed FreeBSD, you might be wondering how to get a shell prompt you’re more used to, ie. BASH. By default, your shell is CSH. There are a few ways to install software using FreeBSD, whichever way you choose you will have to install BASH. I personally prefer using ports, but for simplicity sake, pkg_add -r bash will work. Once installed, you might notice the prompt isn’t the BASH prompt you know and love. Fear not, there is a way to get things set up the way you like it.

Here’s how you do it!

First, we need to chsh to bring up our user preferences, change from CSH (C SHell) to BASH (Bourne Again SHell). Enter the full path to BASH, usually /usr/local/bin/bash).

Bash is optionally installed by the user and is not part of the base system, therefore there is no default ~/.bashrc. You have to make your own. Simply create a blank file, name it .bashrc and save it in your (the user’s) home drive.

Then add the following line to .bashrc.

PS1="[u@h w]# "

That should give you:

[username@hostname /full/path/]# your commands here

This command prompt format is quite popular, for example it’s the default for at least the last few releases of Red Hat and Fedora.

SHARE THIS POST