Changing Your Shell To Bash

Installing the Shell:

This tutorial will discuss installing the bash shell and setting it up as the default for you local user account as well as the root account. Bash has many advantages and is just a nicer, friendlier shell to have around. If you don't like bash and wish to use another one you can follow much of this tutorial but you will have to consult the man pages for the shell you wish to use.

Install the bash port from the ports collection:

# cd /usr/ports/shell/bash2

# make all install clean

# rehash

This will install the bash shell onto your server for use by allowable users. The next step is to configure your local user account to use the bash shell by default and make a much nicer prompt.

Changing your Account Shell

In order to change your shell account you are going to need modify our login information and we must to create/modify two files in your user account home directory.

The first thing to do is change the default prompt for our account:

# chpass username

Change the Shell line to be:

Shell: /usr/local/bin/bash

Now save the changes and exit. Do the same thing for your root account using root as the username. Next we must modify two important files.

The two important files to change are:



We are going to make the same changes to both of the files so you can use the information provided to modify both files for both your local user account and root.

# vi ~username/.bashrc ~username/.bash_profile

The information that we are adding is going to be for the default prompt. We would like to see something that looks like this:


Here are the commands that you should enter to modify the bash prompt:


case `id -u` in

0) PS1="${PS1}# ";;

*) PS1="${PS1}> ";;


This basically says if we are logged in as root use # at the end of the prompt instead of >. A nice little touch don't you think :)

Now let's login into your account and look at your beautiful new shell prompt.