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

OR

# /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

Conclusion

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

FreeBSD Topics 0 Comments

FreeBSD: Disable User’s Login

FreeBSD is a free and open-source Unix-like operating system descended from the Berkeley Software Distribution. It is used to power modern servers, desktops, and embedded platforms. Securing a system running FreeBSD is

Installation 0 Comments

Guided Installation of RedHat 6 on Compaq Smart Array Controller

This post was last updated on May 26th, 2020 at 11:16 pm Step by Step Installation of RedHat 6.0 on a Compaq Server using a Compaq Smart Array Controller RedHat

How To 0 Comments

How To Add Or Remove A User In FreeBSD?

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

0 Comments

No Comments Yet!

You can be first to comment this post!

Leave a Reply