Upgrade bash on Mac OS X Mavericks

Yesterday, I learned quite a lot about different kinds of shells in terms of history, developer, current state and etc. I decided to use bash as my main terminal shell with no hesitation after my researches. However, I found that my bash was of a really old version on my mac. I decided to upgrade it. Here is how I did it.

  1. Install Homebrew, which is a package manager for Mac OS X. It can help to install a lot of useful packages that are omitted by Apple.

    ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"

  2. Use Homebrew to install the newest version of bash (4.2.45)

    brew install bash

  3. The executable file will be placed under /usr/local/bin/bash, so add /usr/local/bin/bash to /etc/shells by your favorite text editor. Don’t forget to use sudo.

    sudo vi /etc/shells

  4. Change your shell


  5. Change the line that has Shell to the location that your newly brew installed bash is located.

    Shell: /usr/local/bin/bash

  6. Restart your terminal

  7. Verify the version of your bash shell

    echo $BASH_VERSION

Unix Basics – Shells, Environment Variables, AFS, ASL



  • Shell basically provides a user interface, mostly command-line interface (CLI) for access to an operating system’s services.
  • A command-line interface (CLI) uses alphanumeric characters typed on a keyboard to provide instructions and data to the operating system, interactively.
  • Operating systems such as UNIX have a large variety of shell programs with different commands, syntax and capabilities.

Bash shell (bash)

  • Bash is a Unix shell written by Brian Fox for the GNU Projects as a free software replacement for the Bourne shell (sh).
  • Bash was released in 1989.
  • Bash is the default shell on Linux and Mac OS X.
  • The name itself is an acronym, a pun, and a description (the part most interests me)
    • Acronym: Bourne-again shell, referring to its objective as a free replacement for the Bourne shell.
    • Pun: it expressed that objective in a phrase that sounds similar to born again, a term for spiritual rebirth.
    • Description: the name is also descriptive of what it did, bashing together the features of sh, csh and ksh.

Bourne shell (sh)

  • Bourne shell, sh, as its abbreviation
  • The Bourne shell was the default Unix shell of Unix Version 7.
  • Most Unix-like system continue to have /bin/sh, which will be the Bourne shell, or a symbolic link or hard link to a compatible shell even when other shells are used by most users.
  • Bourne shell was developed by Stephen Bourne at Bell Labs, it was a replacement for the Thompson shell, whose executable file had the same name—sh.

C shell (csh)

  • C shell was created by Bill Joy while he was a graduate student at University of California, Berkeley in the late 1970s.
  • tcsh is its improved version.
  • What differentiated the C shell from others, especially in the 1980s, were its interactive features and overall style.
  • Its new features made it easier and faster to use. The overall style of the language looked more like C and was seen as more readable.
  • On many systems, such as Mac OS X and Red Hat Linux, csh is actually tcsh.

tcsh (improved version of C shell)

  • tcsh is based on C shell (csh).
  • It is essentially the C shell with programmable command line completion, command-line editing, and a few other features.

Korn shell (ksh)

  • KornShell was developed by David Korn at Bell Labs in the early 1980s and announced at USENIX on July 14, 1983.
  • KornShell is backward-compatible with the Bourne shell and includes many features of the C shell, inspired by the requests of Bell Labs users.

$PATH Variable

  • $PATH is an environment variable on Unix-like operation systems, DOS, OS/2, and Microsoft Windows.
  • $PATH specifies a set of directories where executable programs are located.
  • $PATH variable is specified as a list of one or more directory names separated by colon (:) characters.

  • In order to prevent the accidental execution of scripts residing in the current directory, executing such programs requires the deliberate use of a directory prefix (./) on the command name.

How to change $PATH?

Different shells have different syntaxes.

tsch / csh

bash /sh

~/.cshrc, ~/.bashrc, ~/.bash_profile

  • These are the configuration files for csh (tcsh) and bash.
  • If csh (tcsh) is the login shell, file ~/.cshrc is automatically sourced, followed by ~/.login.
  • If bash is the login shell, ~/.bash_profile will be automatically sourced, but ~/.bashrc will be ignored.
  • If bash is ran as a subshell, ~/.bashrc will be automatically sourced, but ~/.bash_profile will be ignored.
  • My preference is to use bash only.
  • ~/.bash_profile should source ~/.bashrc by adding the following code


  • Andrew File System
  • Distributed file system
  • Developed by Carnegie Mellon University as part of the Andrew Project.
  • Its primary use is in distributed computing.

Access control list (ASL)

  • An access control list (ACL), with respect to a computer file system, is a list of permissions attached to an object.
  • An ACL specifies which users or system processes are granted access to objects, as well as what operations are allowed on given objects.