Understanding Your Unix Environment


Environment variables are settings in the Unix system that specify how you, your shell, and the Unix system interact. When you log in to the Unix system, it sets up your standard environment variablesthe shell prompt you want to use, the default search path, and other information to help programs run, among other things. You might think of your environment variables as being similar to having a standing order with a deli to deliver the same thing to you every day. You set up your "standing environment variables" and the Unix system delivers them to you session after session unless you specify otherwise.

Technically, there is a distinction between "shell" variables, which exist in the particular shell you're using, and "environment" variables, which are in your environment and independent of your particular shell. For most purposes, though, including this book, you can do as we're doing and conveniently blur the distinction. As long as you know that they're not precisely synonymous, you'll be fine.

Basically, just like with the lunch deli, you can configure your environment in one of two ways:

  • Changing the variables for the current sessionkind of like calling in a special order for the day (as in ordering onion and extra cheese on the day's sandwich). You do this from the shell prompt, as discussed in the Adding or Changing Variables section in this chapter.

  • Changing the variables for all subsequent sessionskind of like changing your standard order (say, when the doctor tells you to cut back on mayonnaise and suggests mustard for your long-term deli order). You do this within the configuration files, as discussed in sections following Adding or Changing Variables.

If you want to change your environment variables, you should first try changing them from the shell prompt for the current session. This way, you can try out the changes before you make them permanent in your configuration files.

When you do change your environment in the configuration files, keep in mind that configuration files are generally run in a specific order:

  • Systemwide configuration files (such as /etc/profile) run first upon log in. These systemwide configuration files in /etc (if they exist) help set up your environment, but you cannot change them.

  • Configuration files specific to your Unix account (such as ~/.profile and ~/.kshrc) run next if they're available. If you want to change environment variables originally set in the systemwide files, you can reset the values in your own personal files.

What this order means to you is that your own personal configurations override system ones. So, in making changes to your configuration files, make sure that you make changes to the configuration file that runs last. We'll tell you which specific files to look for in the relevant sections of this chapter.

Find out about discovering your current environment variables and adding or changing environment variables manually in the next two sections in this chapter.

Tips

  • You can use echo $SHELL to remind yourself of what shell you're using. Visit Chapter 3 for more details.

  • Find out about changing environment variables in your system configuration files in other sections of this chapter, according to which shell you're using.





Unix(c) Visual Quickstart Guide
UNIX, Third Edition
ISBN: 0321442458
EAN: 2147483647
Year: 2006
Pages: 251

Similar book on Amazon

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