OpenBSD Install BASH Shell Package Command

Get real time updates directly on you device, subscribe now.

How do I install BASH shell package under OpenBSD operating system? How do I set bash as a default login shell under OpenBSD?

You need to use the pkg_add command to install BASH package which is available in a binary packages format over the Internet. You can also install bash package using OpenBSD CD.

First, Login as a root user, either use su - or sudo or doas command.

Next setup PKG_PATH using export command. You can make things really easy by using the PKG_PATH environment variable. Just point it to your favorite location, and pkg_add will automatically look there for any package you specify, and also fetch and install the necessary dependencies of this package automatically (see mirror list here).
$ export PKG_PATH=`uname -r`/packages/`machine -a`/
Or add to your ~/.profile (sh/ksh/bash) file as follows:

echo 'export PKG_PATH=`uname -r`/packages/`machine -a`/' >> ~/.profile

echo ‘export PKG_PATH=`uname -r`/packages/`machine -a`/’ >> ~/.profile

Caution: The PKG_PATH variable MUST end in a slash (/).

OpenBSD Install bash shell binary package

Use pkg_add command as follows (older version):
# pkg_add -i -v bash
OR on newer system:
# pkg_add -v bash
OR use doas as follows (if configured on your system):
$ doas -u root pkg_add -v bash
Sample outputs from OpenBSD 4.x:

parsing bash-3.2
Dependencies for bash-3.2 resolve to: gettext-0.14.6, libiconv-1.9.2p3 (todo: libiconv-1.9.2p3,gettext-0.14.6)
bash-3.2:parsing libiconv-1.9.2p3
bash-3.2:libiconv-1.9.2p3: complete                                                                                                                                           
bash-3.2:parsing gettext-0.14.6
Dependencies for gettext-0.14.6 resolve to: expat-2.0.0, libiconv-1.9.2p3 (todo: expat-2.0.0)
bash-3.2:parsing expat-2.0.0
bash-3.2:expat-2.0.0: complete                                                                                                                                                
bash-3.2:gettext-0.14.6: complete                                                                                                                                             
Shell /usr/local/bin/bash appended to /etc/shells
bash-3.2: complete

Sample outputs from OpenBSD 5.9 (please note that you no longer need to pass the -i option to OpenBSD):

Fig.01: Installing bash shell on OpenBSD 5.9

To use bash shell, just enter bash command:

$ bash

How do I setup bash as a login and default shell for my account?

Type the following command to change the user’s shell to new shell called /usr/local/bin/bash (the following will change root shell to bash):
# chsh -s /usr/local/bin/bash
Set bash shell as a default login shell for user nixcraft:
# chsh -s /usr/local/bin/bash nixcraft

Posted by: SXI ADMIN

The author is the creator of SXI LLC and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Get real time updates directly on you device, subscribe now.