Admin... by accident!

You may have chosen to be an admin. I didn't!

  • Home
  • FreeBSD
  • GNU/Linux
  • Security
  • Network
  • Virtualization
  • Politics
  • Github
  • Donate
  • Me

How to install the bash shell on FreeBSD

January 28, 2019 by Albert Valbuena

Believe it or not the Bash shell does not come installed on the system. By default FreeBSD uses the sh shell (after the rewrite under the BSD license on 1989 of the original Bourne Shell found on UNIX, which had inherited the ‘sh’ name from the original’s Thomson shell), the C shell or the tcsh shell. As on any other UNIX system you can change the shell and install others that do not come on the base system, say the dash shell or the zsh one. For a regular user changing the default shell does mean almost nothing, specially if this is going to be used as a regular PC. However if you are going to use this system as a development machine or the like you may want to use a different shell. The Bash shell is a very popular one among programmers nowadays and system administrators as well. Hence this short simple article on how to install the bash shell on FreeBSD.

If you find the articles in Adminbyaccident.com useful to you, please consider making a donation.

Use this link to get $200 credit at DigitalOcean and support Adminbyaccident.com costs.

Get $100 credit for free at Vultr using this link and support Adminbyaccident.com costs.

Mind Vultr supports FreeBSD on their VPS offer.

So you said you wanted bash. Let’s install it. Before anything update your pkg source by:

sudo pkg upgrade

Let’s now install bash:

albert@Apache:~ % sudo pkg install bash

Updating FreeBSD repository catalogue...

FreeBSD repository is up to date.

All repositories are up to date.

The following 1 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:

bash: 4.4.23_1

Number of packages to be installed: 1

The process will require 8 MiB more space.

1 MiB to be downloaded.

Proceed with this action? [y/N]: y

[Apache] [1/1] Fetching bash-4.4.23_1.txz: 100% 1 MiB 488.8kB/s 00:03

Checking integrity... done (0 conflicting)

[Apache] [1/1] Installing bash-4.4.23_1...

[Apache] [1/1] Extracting bash-4.4.23_1: 100%

albert@Apache:~ %

You may also want tab auto-completion so you want to install the bash-completion package.

albert@Apache:~ % sudo pkg install bash-completion

Updating FreeBSD repository catalogue...

FreeBSD repository is up to date.

All repositories are up to date.

The following 1 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:

bash-completion: 2.8_1,1

Number of packages to be installed: 1

199 KiB to be downloaded.

Proceed with this action? [y/N]: y

[Apache] [1/1] Fetching bash-completion-2.8_1,1.txz: 100% 199 KiB 68.0kB/s 00:03

Checking integrity... done (0 conflicting)

[Apache] [1/1] Installing bash-completion-2.8_1,1...

[Apache] [1/1] Extracting bash-completion-2.8_1,1: 100%

Message from bash-completion-2.8_1,1:

=====================================================================

To enable the bash completion library, add the following to

your .bashrc file:

[[ $PS1 && -f /usr/local/share/bash-completion/bash_completion.sh ]] && \

source /usr/local/share/bash-completion/bash_completion.sh

See /usr/local/share/doc/bash-completion/README.md for more information.

=====================================================================

albert@Apache:~ %

You can already change your default shell to use bash if that is what you desire. Use the handbook chapter to do so.

https://www.freebsd.org/doc/handbook/shells.html

However you may want to configure bash just a bit. If so read on this how to install the bash shell on FreeBSD guide.

You have to create a configuration file named .bashrc, .bash_profile inside your home directory.

albert@Apache:~ % touch .bashrc

albert@Apache:~ %

This file is empty. Let’s fill it up.

For the auto-completion to work you may add what you were told at install time:

[[ $PS1 && -f /usr/local/share/bash-completion/bash_completion.sh ]] && \

source /usr/local/share/bash-completion/bash_completion.sh

Now you may want to add a few aliases. An alias works to avoid typing a command an a series of flags. For example the ‘ll’ command is the short form of ‘ls -la’. These are the aliases I’ve added to mine:

alias l='ls -CF'

alias la='ls -A'

alias ll='ls -lhA'

You may want to add some color to the ouput of the shell. There is a environment variable you can enable by adding the following to your bash config file:

export CLICOLOR="YES"

export LSCOLORS="ExGxFxdxCxDxDxhbadExEx"

To make use of bash with this configuration you can just type ‘bash’ at your command prompt and you will see the change.

albert@Workstation:~ %

albert@Workstation:~ % bash

[albert@Workstation ~]$

Notice the brackets and the dollar sign instead of the percentage at the end of the line.

If you want the bash shell to be your default shell you can do it by following what the manual states. In short here you have it:

Find the path of the bash binary.

[albert@Workstation ~]$ which bash

/usr/local/bin/bash

[albert@Workstation ~]$

With the path use the change shell command.

albert@Apache:~ % chsh -s /usr/local/bin/bash albert

Password:

chsh: user information updated

albert@Apache:~ %

Log out of all your sessions and get back in. By default your shell should’ve changed. In order to check it you can do:

albert@Apache:~ % finger albert

Login: albert Name: Albert Valbuena

Directory: /home/albert Shell: /usr/local/bin/bash

Last login Sun Nov 4 21:05 (CET) on pts/3 from 192.168.1.35

No Mail.

No Plan.

albert@Apache:~ %

When logged back in:

[albert@Apache ~]$ finger albert

Login: albert Name: Albert Valbuena

Directory: /home/albert Shell: /usr/local/bin/bash

Last login Sun Nov 4 21:05 (CET) on pts/3 from 192.168.1.35

No Mail.

No Plan.

[albert@Apache ~]$

As a last note take in consideration that bash doesn’t need the fdescfs (file-descriptor file system) mounted at runtime. But some GNU/Linux scripts may need it so. To momentarily enable the functionality type the following:

mount -t fdescfs null /dev/fd

In order to make this last thing permanent edit the /etc/fstab file and add the following line:

fdesc /dev/fd fdescfs rw 0 0

You can go crazy configuring bash. There are many other guides on the internet for you to follow. Use whatever fits your needs and enjoy your time with it. This is all for my how to install the bash shell on FreeBSD guide.

If you find the articles in Adminbyaccident.com useful to you, please consider making a donation.

Use this link to get $200 credit at DigitalOcean and support Adminbyaccident.com costs.

Get $100 credit for free at Vultr using this link and support Adminbyaccident.com costs.

Mind Vultr supports FreeBSD on their VPS offer.

 

Filed Under: FreeBSD, How To's

Recent Posts

  • How to install Redis for WordPress on FreeBSD
  • How to compile cloudflared in FreeBSD 13/14
  • How to configure FreeBSD to use a webcam (version 12 and 13)
  • Symbolic and Hard Links in UNIX and Linux
  • How to import iocage jails to Bastille on FreeBSD 13
  • How to load and unload kernel modules in Linux
  • How to use find in GNU/Linux and FreeBSD
  • How to install Mate on FreeBSD 12/13
  • How to install Nessus 10 on FreeBSD 12
  • How to enable TLS traffic from the origin server on Cloudflare Argo Tunnel
  • How to use Cloudflare’s Argo Tunnel service to publish a website on FreeBSD 12/13
  • How to setup MariaDB master-slave replication on FreeBSD
  • How to upload a FreeBSD custom image on DigitalOcean
  • How to install Drupal 9 on FreeBSD 13.0
  • How to manage site visitors based on IP Geolocation
  • How to enable Geolocation in AWStats on FreeBSD 13.0
  • How to install AWStats on FreeBSD 13.0
  • How to configure Modsecurity 3 for WordPress on FreeBSD
  • How to configure Apache HTTP with a TLS reverse proxy backend on FreeBSD
  • How to detect a WAF – Web Application Firewall

Archives

  • November 2024
  • October 2024
  • August 2023
  • July 2023
  • June 2023
  • May 2023
  • April 2023
  • February 2023
  • January 2023
  • December 2022
  • April 2022
  • March 2022
  • October 2021
  • September 2021
  • June 2021
  • May 2021
  • April 2021
  • March 2021
  • February 2021
  • January 2021
  • December 2020
  • July 2020
  • June 2020
  • May 2020
  • April 2020
  • March 2020
  • February 2020
  • January 2020
  • December 2019
  • November 2019
  • October 2019
  • August 2019
  • July 2019
  • June 2019
  • May 2019
  • April 2019
  • March 2019
  • February 2019
  • January 2019
  • September 2018
  • June 2018
  • May 2018
  • April 2018
  • February 2018
  • January 2018
  • November 2017
  • April 2017

RSS Admin… by accident!

  • How to install Redis for WordPress on FreeBSD
  • How to compile cloudflared in FreeBSD 13/14
  • How to configure FreeBSD to use a webcam (version 12 and 13)
  • Symbolic and Hard Links in UNIX and Linux
  • How to import iocage jails to Bastille on FreeBSD 13
  • How to load and unload kernel modules in Linux
  • How to use find in GNU/Linux and FreeBSD
  • How to install Mate on FreeBSD 12/13
  • How to install Nessus 10 on FreeBSD 12
  • How to enable TLS traffic from the origin server on Cloudflare Argo Tunnel

Copyright © 2025 · Magazine Pro Theme on Genesis Framework · WordPress · Log in