Getting bash

1.4 Getting bash

You may or may not be using bash right now. Your system administrator probably set your account up with whatever shell he or she uses as the "standard" on the system. You may not even have been aware that there is more than one shell available.

Yet it's easy for you to determine which shell you are using. Log in to your system and type echo $SHELL at the prompt. You will see a response containing sh , csh , ksh , or bash ; these denote the Bourne, C, Korn, and bash shells , respectively. (There's also a chance that you're using another shell such as tcsh .)

If you aren't using bash and you want to, then you first need to find out if it exists on your system. Just type bash . If you get a new prompt consisting of some information followed by a dollar-sign (e.g: bash2-2.01$ ), then all is well; type exit to go back to your normal shell.

If you get a "not found" message, your system may not have it. Ask your system administrator or another knowledgeable user ; there's a chance that you might have some version of bash installed on the system in a place (directory) that is not normally accessible to you. If not, read Chapter 11 , to find out how you can obtain a version of bash .

Once you know you have bash on your system, you can invoke it from whatever other shell you use by typing bash as above. However, it's much better to install it as your login shell , i.e., the shell that you get automatically whenever you log in. You may be able to do the installation by yourself. Here are instructions that are designed to work on the widest variety of UNIX systems. If something doesn't work (e.g., you type in a command and get a "not found" error message or a blank line as the response), you'll have to abort the process and see your system administrator or, alternatively, turn to Chapter 11 where we demonstrate a less straightforward way of replacing your current shell.

You need to find out where bash is on your system, i.e., in which directory it's installed. You might be able to find the location by typing whereis bash ( especially if you are using the C shell); if that doesn't work, try whence bash , which bash , or this complex command: [2]

[2] Make sure you use the correct quotation mark in this command: ' rather than ` .

grep bash /etc/passwd | awk -F: '{print }' | sort -u

You should see a response that looks like /bin/bash or /usr/local/bin/bash .

To install bash as your login shell, type chsh bash- name , where bash-name is the response you got to your whereis command (or whatever worked). For example:

% chsh /usr/local/bin/bash

You'll either get an error message saying that the shell is invalid, or you'll be prompted for your password. [3] Type in your password, then log out and log back in again to start using bash .

[3] For system security reasons, only certain programs are allowed to be installed as login shells.


Learning the Bash Shell
Learning the bash Shell: Unix Shell Programming (In a Nutshell (OReilly))
ISBN: 0596009658
EAN: 2147483647
Year: 1998
Pages: 104

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: