FreeBSD Install BASH Shell

by on January 13, 2008 · 9 comments· LAST UPDATED May 7, 2012

in , ,

I'd like to Bash shell under FreeBSD for bash programming. How do I install bash shell under FreeBSD UNIX operating system?

Bash is an sh-compatible command language interpreter that executes commands read from the standard input or from a file. csh / tcsh (C shell with file name completion and command line editing) is the default shell under FreeBSD. However, you can easily install and use bash as shell.

Install bash under FreeBSD

Login as root and type the following commands to install bash using FreeBSD ports:
# portsnap update extract
# cd /usr/ports/shells/bash
# make install clean

To install FreeBSD binary package, enter:
# pkg_add -r bash

How do I use bash under FreeBSD?

To use bash shell, enter:
# bash
# /usr/local/bin/bash

How do I set bash as a default shell?

To set bash as default, shell enter:
# chsh -s /usr/local/bin/bash {username}
# chsh -s /usr/local/bin/bash vivek
# chsh -s bash

Verify that bash is default shell for a user account called vivek, enter:
grep vivek /etc/passwd

egrep --color 'vivek|zsh' /etc/passwd

finger vivek
Sample outputs:

Login: vivek          			Name: Vivek Gite
Directory: /home/vivek              	Shell: /usr/local/bin/bash
On since Tue May  8 02:15 (IST) on pts/0 from
No Mail.
No Plan.
Tweet itFacebook itG+ itDownload PDF versionFound an error/typo on this page?

{ 9 comments… read them below or add one }

1 duzap May 22, 2009 at 8:12 am

This was very usefull for me, thank you.


2 matt November 22, 2009 at 6:43 pm


Just trying out freebsd, and the first thing I noticed was there was no bash!


3 Nazar August 4, 2010 at 1:00 am

Thanks a lot! Very clearly written and useful!


4 DJNeo August 5, 2010 at 2:14 am

Very usefull,10x alot!!!


5 George December 14, 2010 at 12:09 pm

Thanks a lot! Exactly what I needed!


6 Chuck Moyes March 22, 2011 at 8:50 pm

I think the portsnap part (updating the system port tree) needs clarification.

From the FreeBSD Handbook:

First run:
# portsnap fetch
to download a new port tree from the Internet.

If you haven’t run portsnap before (first time updating after new installation):
# portsnap extract

Then always run:
# portsnap update

FreeBSD complained about running update before extract when I tried doing what the guide on this web page said to do. Let me know if I’m misinterpreting something.


7 Rui March 28, 2011 at 10:46 pm

Thank you!!!:)


8 Alex June 10, 2012 at 10:27 am

Thanks a lot! Just used it. =)


9 Uwe September 24, 2012 at 8:25 pm

Thank you for this post. It was very useful for me!


Leave a Comment

Tagged as: , , , , , , , , , ,

Previous Faq:

Next Faq: