≡ Menu

FreeBSD Install BASH Shell

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

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

OR
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 192.168.1.5
No Mail.
No Plan.
Tweet itFacebook itGoogle+ itPDF itFound an error/typo on this page?

{ 9 comments… add one }

  • duzap May 22, 2009, 8:12 am

    This was very usefull for me, thank you.

  • matt November 22, 2009, 6:43 pm

    Thanks,

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

  • Nazar August 4, 2010, 1:00 am

    Thanks a lot! Very clearly written and useful!

  • DJNeo August 5, 2010, 2:14 am

    Very usefull,10x alot!!!

  • George December 14, 2010, 12:09 pm

    Thanks a lot! Exactly what I needed!

  • Chuck Moyes March 22, 2011, 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.

  • Rui March 28, 2011, 10:46 pm

    Thank you!!!:)

  • Alex June 10, 2012, 10:27 am

    Thanks a lot! Just used it. =)

  • Uwe September 24, 2012, 8:25 pm

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

Leave a Comment