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.
You should follow me on twitter here or grab rss feed to keep track of new changes.
Featured Articles:
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012

- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop













{ 9 comments… read them below or add one }
This was very usefull for me, thank you.
Thanks,
Just trying out freebsd, and the first thing I noticed was there was no bash!
Thanks a lot! Very clearly written and useful!
Very usefull,10x alot!!!
Thanks a lot! Exactly what I needed!
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.
Thank you!!!:)
Thanks a lot! Just used it. =)
Thank you for this post. It was very useful for me!