Getting bash for Linux

Problem

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

Solution

bash is included in virtually all modern Linux distributions. To make sure you have the latest version available for your distribution, use the distribution’s built-in packaging tools. You must be root or have the root password to upgrade or install applications.

Some Linux distributions (notably Debian) include bash version 2.x as plain bash and version 3.x as bash3, so you need to watch out for that. Table 1-1 lists the default versions as of early 2007 (distributions update their repositories often, so versions might have changed from this listing).

Table 1-1. Default Linux distributions

Distribution

2.x in base install

2.x in updates

3.x in base install

3.x in updates

Debian Woody

2.05a

N/A

N/A

N/A

Debian Sarge[a]

2.05b

3.1dfsg-8 (testing & unstable)

3.0-12(1)-release

3.00.16(1)-release

Fedora Core 1

bash-2.05b-31.i386.rpm

bash-2.05b-34.i386.rpm

N/A

N/A

Fedora Core 2

bash-2.05b-38.i386.rpm

N/A

N/A

N/A

Fedora Core3

N/A

N/A

bash-3.0-17.i386.rpm

bash-3.0-18.i386.rpm

Fedora Core 4

N/A

N/A

bash-3.0-31.i386.rpm

N/A

Fedora Core 5

N/A

N/A

bash-3.1-6.2.i386.rpm

bash-3.1-9.fc5.1.i386.rpm

Fedora Core 6

N/A

N/A

bash-3.1-16.1.i386.rpm

N/A

Knoppix 3.9 & 4.0.2

N/A

N/A

3.0-15

N/A

Mandrake 9.2[b]

bash-2.05b-14mdk.i586.rpm

N/A

N/A

N/A

Mandrake 10.1[c]

bash-2.05b-22mdk.i586.rpm

N/A

N/A

N/A

Mandrake 10.2[d]

N/A

N/A

bash-3.0-2mdk.i586.rpm

N/A

Mandriva 2006.0[e]

N/A

N/A

bash-3.0-6mdk.i586.rpm

N/A

Mandriva 2007.0[f]

N/A

N/A

bash-3.1-7mdv2007.0.i586.rpm

N/A

OpenSUSE 10.0

N/A

N/A

3.00.16(1)-release

3.0.17(1)-release

OpenSUSE 10.1

N/A

N/A

3.1.16(1)-release

N/A

OpenSUSE 10.2

N/A

N/A

bash-3.1-55.i586.rpm

N/A

SLED 10 RC3

N/A

N/A

3.1.17(1)-release

N/A

RHEL 3.6, CentOS 3.6

bash-2.05b.0(1)

N/A

N/A

N/A

RHEL 4.4, CentOS 4.4

N/A

N/A

3.00.15(1)-release

N/A

MEPIS 3.3.1

N/A

N/A

3.0-14

N/A

Ubuntu 5.10[g]

N/A

N/A

3.0.16(1)

N/A

Ubuntu 6.06[h]

N/A

N/A

3.1.17(1)-release

N/A

Ubuntu 6.10[i]

N/A

N/A

3.1.17(1)-release

N/A

[a] Debian Sarge: see also bash-builtins, bash-doc, bash-minimal, bash-static, bash3-doc

[b] Mandrake 9.2: bash-completion-20030821-3mdk.noarch.rpm, bash-doc-2.05b-14mdk.i586.rpm, bash1-1.14.7-31mdk.i586.rpm

[c] Mandrake 10.1: see also bash-completion-20040711-1mdk.noarch.rpm, bash-doc-2.05b-22mdk.i586.rpm, bash1-1.14.7-31mdk.i586.rpm

[d] Mandrake 10.2: see also bash-completion-20050121-2mdk.noarch.rpm, bash-doc-3.0-2mdk.i586.rpm

[e] Mandriva 2006.0: see also bash-completion-20050721-1mdk.noarch.rpm, bash-doc-3.0-6mdk.i586.rpm

[f] Mandriva 2007.0: see also bash-completion-20060301-5mdv2007.0.noarch.rpm, bash-doc-3.1-7mdv2007.0.i586.rpm

[g] Ubuntu: see also the bash-builtins, bash-doc, bash-static, and abs-guide packages

[h] Ubuntu: see also the bash-builtins, bash-doc, bash-static, and abs-guide packages

[i] Ubuntu 6.10 symlinks dash to /bin/sh instead of bash as previous versions of Ubuntu and most other Linux distributions (https://wiki.ubuntu.com/DashAsBinSh)

For Debian and Debian-derived systems such as Knoppix, Ubuntu, and MEPIS, make sure your /etc/apt/sources.list file is pointing at an up-to-date Debian mirror; then use the graphical Synaptic, kpackage, gnome-apt, or Add/Remove Programs tools, the terminal-based aptitude tool, or from the command line:

apt-get update && apt-get install bash bash3 bash-builtins bash-doc bash3-doc

For Red Hat distributions, including Fedora Core (FC) and Red Hat Enterprise Linux (RHEL), use the GUI Add/Remove Applications tool (if the GUI is missing from the menus, at a command line for RHEL3 type redhat-config-packages & or for RHEL4 type system-config-packages &). For a command line only:

up2date install bash

For Fedora Core and CentOS, you may use the above RHEL directions or from the command line:

yum update bash

For SUSE, use either the GUI or terminal version of YaST. You may also use the command-line RPM tool.

For Mandriva/Mandrake, use the GUI Rpmdrake tool or from the command line:

urpmi bash

Discussion

It’s impossible to cover every Linux distribution and difficult even to cover the major ones, as they are all evolving rapidly. Fortunately, much of that evolution is in the area of ease-of-use, so it should not be very difficult to figure out how to install software on your distribution of choice.

When using Knoppix, Ubuntu, or other Live CDs, software updates and installations will most likely fail due to the read-only media. Versions of such distributions that have been installed to a hard disk should be updatable.

The apt-get update && apt-get install bash bash3 bash-builtins bash-doc bash3-doc command above will generate errors on systems that do not provide a bash3 package. You may safely ignore such errors.

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.