1.4. Getting bash

 < Day Day Up > 

You may or may not be using bash right now. Your system administrator probably set your account up with whatever shell he 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., bash3 $ ), 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. Alternatively, turn to Chapter 12 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:[3]

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

grep bash /etc/passwd | awk -F: '{print $7}' | 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.[4] Type in your password, then log out and log back in again to start using bash.

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

     < Day Day Up > 


    Learning the bash Shell
    Learning the bash Shell: Unix Shell Programming (In a Nutshell (OReilly))
    ISBN: 0596009658
    EAN: 2147483647
    Year: 2005
    Pages: 139

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net