FreeBSD: Install And Use Bash Shell

FreeBSD: Install And Use Bash Shell


This post was last updated on August 1st, 2020 at 09:11 am

In Unix like operating systems, a shell is a program that interprets the command, executes, takes input(s), and prints output(s) on the terminal. FreeBSD uses tcsh as the default root shell and sh as the default user shell.

For the purpose of bash scripting, you might need it in FreeBSD. So this article describes how to install and use bash in FreeBSD.

What is bash

Bash is a command-line shell/programming language by the GNU project. Bash or bourne again shell is a sh compatible shell that includes the useful feature of Korn shell(ksh) and C shell(csh). It comes default in various Unix like operating systems such as in GNU/Linux.

How to install bash in FreeBSD

In FreeBSD, there are two ways to install software packages: pkg and ports collection. The pkg is used to install from prebuilt binaries while ports collection is used to install packages from sources. You can use either way to install the bash in your system.

Installing bash using pkg

To install bash using pkg use the following command in your terminal –

# pkg install bash

Installing bash using the ports collection

To install the bash using the ports collection, first, you have to change the directory to the port bash –

# cd /usr/ports/shells/bash

and then use –

# make install clean

Please note that you need to be a root user or have superuser privilege for installing packages in FreeBSD.

Working with the bash shell in FreeBSD

Now bash is installed in your system you can start using it by executing the following command –

# bash


# /usr/local/bin/bash

This will change the current shell into the bash.

How to set bash as default shell

First, find the location where bash is installed by using –

# whereis bash

To set bash as the default shell for the current user, use-

# chsh -s /usr/local/bin/bash

Or if you want to set it the default for another user then use –

# chsh -s /usr/local/bin/bash {Username}

For example –

# chsh -s /usr/local/bin/bash lalit

Now if you want to set tcsh or sh your default shell again then use –

# chsh -s /bin/tcsh

OR use –

# chsh -s /bin/sh


After installing bash, you could now add the bash-completion feature in your system. If you want to say something on this topic then write to us in the comments below.

Previous [server] No ping only with Windows, but it works with Ubuntu (Dual boot)
Next How To Add Bash Auto Completion In FreeBSD?

About author

You might also like

How To 0 Comments

How To Execute A Command With Superuser Privilege In FreeBSD?

This post was last updated on August 1st, 2020 at 10:28 amA superuser or root user is a most privileged user account in FreeBSD. It has access to all the

FreeBSD 0 Comments

How To Install And Configure Gnome Desktop in FreeBSD?

This post was last updated on August 1st, 2020 at 12:05 pmFreeBSD is a free and open-source Unix-like operating system descended from the Berkeley Software Distribution. It is used to power

Linux Development 2 Comments

How To Install PyCharm In Linux Mint?

This post was last updated on August 1st, 2020 at 04:26 pmThe PyCharm is a fully-featured IDE for python. It is developed by JetBrains. PyCharm supports many other programming languages


No Comments Yet!

You can be first to comment this post!

Leave a Reply