Shell Configuration


Like almost every other part of a Unix system, the shell is highly configurable. As it's the place where you type your commands and do a lot of complex work, you're going to want to tweak it until it feels comfortable.

Every Unix shell, be it the Bourne Again shell (bash) used on Fedora Core, Mac OS X, and Cygwin systems, or the C shell (csh) used on FreeBSD, supports global configuration files for sitewide changes, and local, user-specific configuration files.

To find the global shell-configuration files

As you might have noticed earlier, the global shell-configuration files live in the same directory as the system-startup files.

1.

cd /etc

Change to the system-configuration-files directory.

2.

echo $SHELL

Find out which shell you're currently using. If you already know, you can skip this step.

This detail is important, because each shell uses different configuration files.

3.

If your shell is sh (usually /bin/sh), it will use the /etc/profile file.

If your shell is bash (usually /usr/local/bash or /bin/bash), it will also use the /etc/profile file.

If your shell is csh (usually /bin/csh or /bin/tcsh), it will use /etc/csh.cshrc and then /etc/csh.login.

Even though the shell loads these files first, the local shell-configuration files can change anything set up by the global configuration files.

To find the local shell-configuration files

Your local shell-configuration file also depends on which shell you're using, but they're always in your HOME directory.

1.

echo $SHELL

Find out which shell you're using. You can skip this step if you already know.

2.

If your shell is sh, it will use the following local configuration files:

  • .profile, if any

  • The file specified in the ENV environment variable, if any

If your shell is bash, it will use the following local configuration files:

  • .bash_profile, if any, if bash was invoked as a login shell (or with the --login option)

  • .bash_login, if any, if bash was invoked as a login shell (or with the --login option)

  • .profile, if any, if bash was invoked as a login shell (or with the --login option)

  • .bashrc, if any, if bash was invoked as a non-login shell

  • The file specified in the BASH_ENV environment variable, if any

  • .bash_logout, if any (only when exiting the shell)

If your shell is csh, it will use the following local configuration files:

  • .cshrc, if any

  • .login, if any

To customize your shell

1.

Edit the appropriate configuration file using your favorite text editor. If you want these changes to apply to all users, edit the global files; otherwise, edit your local files.

2.

Add useful directories to your PATH environment variable.

In sh or bash:

 export PATH=new-path:$PATH 

In csh:

 setenv PATH new-path:$PATH 

new-path can be /usr/local/bin or any other directory with binaries in it; I usually add ~/bin to my PATH and put my own programs in there.

3.

Add any other environment variables you might need. These will be specific to the programs you use, so you'll have to consult the documentation for details.

4.

Add aliases or shell functions. For example, I like to add this one, since I'm used to having lc because of an old Unix system I used in school:

 alias lc="ls -F" 



    Unix Advanced. Visual QuickPro Guide
    Unix Advanced: Visual QuickPro Guide
    ISBN: 0321205499
    EAN: 2147483647
    Year: 2003
    Pages: 116

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