LINUX TIPS AND TRICKS --- December 08, 2000

Published by ITworld.com, the IT problem-solving network
http://www.itworld.com/newsletters

--------------------------------------------------------------------------------

Shell Configuration Files
By Danny Kalev

This week I will discuss shell configuration files and their uses. 

Shell configuration files are executed automatically when you log in and
out of a shell. They initialize and configure a shell upon login and
perform cleanup operations upon logout.

BASH
BASH defines three configurations files: .bash_profile, .bashrc, and
.bash_logout. .bash_profile contains initialization commands that set
environment variables, a shell's prompt and so on. The .bashrc contains
commands that configure the shell, define command aliases and set
command shell options. .bash_profile is executed automatically when a
user logs into a shell, along with .bashrc. The .bash_logout file is
executed when the user logs out of a shell. .bash_logout contains
cleanup operations and other commands that you want the shell to execute
whenever a user logs out of a shell. For example, it can include
commands that clear the screen and print a farewell message. Unlike the
.bash_profile file, which is created automatically when you open a new
account, you have to create the .bash_logout by yourself using a text
editor such as vi, emacs, etc.
In the following example, the .bash_logout file contains commands that
clear the screen and print a reminder to the user to take her diskette
from the disk drive:

  clear
  echo "don't forget to remove your homework exercises diskette from the
diskette drive!"

Other Shells
Other shells have similar configuration files, albeit with different
names. Thus, instead of the BASH .bash_profile, .bashrc, and
.bash_logout configuration files, TCSH uses the .login, .tcshrc  and
.logout configuration files, respectively. Likewise, Z-shell uses the
files .zshenv, .zprofile, and .zlogin for initialization, .zshrc as a
configuration file equivalent to .bashrc, and .zlogout as the equivalent
of .bash_logout. The PDKSH shell uses the .profile and .kshrc files for
initialization and shell configuration, respectively.

A correction 
In last week's newsletter, the meaning of the arguments +o and -o got
inverted. The +o argument actually turns a feature off whereas -o turns
it on. Thanks to all the readers who have drawn my attention to this
typo.


About the author(s)
----------------
Danny Kalev is a system analyst and software engineer with more than 10 
years of experience, specializing in C++ and object-oriented analysis 
and design on various platforms including VMS, DOS, Windows, Unix, and 
Linux. His technical interests involve code optimization, networking, 
and distributed computing. He is also a member of the ANSI C++ 
standardization committee and the author of ANSI/ISO C++ Professional 
Programmer's Handbook (Que, 1999). Contact him at linuxnl@excite.com. 

--------------------------------------------------------------------------------

ADDITIONAL RESOURCES

Command-line NT: It does exist! 
Less featureful, less elegant -- but there 
http://www.itworld.com/jlw/lintps_nl/lw-1999-04/lw-04-thereandback_p.html

Shell programming and simple menus - part 1 
The anatomy of a menu shell script 
http://www.itworld.com/jsw/lintps_nl/swol-07-1997/swol-07-unix101.html

Shell programming and simple menus - part 2 
Getting more mileage out of your menu 
http://www.itworld.com/jsw/lintps_nl/swol-08-1997/swol-08-unix101.html

--------------------------------------------------------------------------------

COMMUNITY DISCUSSIONS

Hone your Linux development skills, share your expertise, and put out 
the occasional call for help in this discussion for programmers of all 
levels. Moderated by Danny Kalev. 
http://www.itworld.com/jump/lintps_nl/forums.itworld.com/webx?14@@.ee6b652/198!skip=138

Ask questions, offer solutions, and tell your tales in this lively 
discussion of the good, bad, and ugly sides of managing Unix systems. 
http://www.itworld.com/jump/lintps_nl/forums.itworld.com/webx?14@@.ee6b677

--------------------------------------------------------------------------------

CONTACTS

* For editorial comments, write Andrew Santosusso, Associate Editor, 
  Newsletters at: andrew_santosusso@itworld.com

* For advertising information, write Dan Chupka, Account Executive at:
  dan_chupka@itworld.com

* For recruitment advertising information, write Jamie Swartz, Eastern
  Regional Sales Manager at: jamie_swartz@itworld.com or Paul Duthie,
  Western Regional Sales Manager at: paul_duthie@itworld.com

* For all other inquiries, write Jodie Naze, Product Manager, 
  Newsletters at: jodie_naze@itworld.com

--------------------------------------------------------------------------------

PRIVACY POLICY
http://www2.itworld.com/CDA/ITW_Privacy_Policy 

Copyright 2000 ITworld.com, Inc., All Rights Reserved.

http://www.itworld.com
