Getting bash for xBSD

Problem

You want to get bash for your FreeBSD, NetBSD, or OpenBSD system, or you want to make sure you have the latest version.

Solution

To see if bash is installed, check the /etc/shells file. To install or update bash, use the pkg_add command. If you are an experienced BSD user, you may prefer using the ports collection, but we will not cover that here.

FreeBSD:

pkg_add -vr bash

For NetBSD, browse to Application Software for NetBSD at http://netbsd.org/Documentation/software/ and locate the latest bash package for your version and architecture, then use a command such as:

pkg_add -vu ftp://ftp.netbsd.org/pub/NetBSD/packages/pkgsrc-2005Q3/NetBSD-2.0/i386/
All/bash-3.0pl16nb3.tgz

For OpenBSD, you use the pkg_add -vr command. You may have to adjust the FTP path for your version and architecture. Also, there may be a statically compiled version. For example: ftp://ftp.openbsd.org/pub/OpenBSD/3.8/packages/i386/bash-3.0.16p1-static.tgz.

pkg_add -vr ftp://ftp.openbsd.org/pub/OpenBSD/3.8/packages/i386/bash-3.0.16p1.tgz

Discussion

FreeBSD and OpenBSD place bash in /usr/local/bin/bash while NetBSD uses /usr/pkg/ bin/bash.

Interestingly, PC-BSD 1.2, a “rock-solid Unix operating system based on FreeBSD,” comes with bash 3.1.17(0) in /usr/local/bin/bash, though the default shell is still csh.

Get bash Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.