A good first step in changing your environment is determining what environment you have. Using the steps in this section, you can discover which environment and shell variables are currently set—including ones set in the configuration files as well as ones you’ve set for the current session (Code Listings 8.1 and 8.2).
[ejr@hobbes ejr]$ set
BASH=/bin/bash
BASH_VERSION=1.14.7(1)
COLUMNS=80
ENV=/home/ejr/.bashrc
EUID=500
HISTFILE=/home/ejr/.bash_history
HISTFILESIZE=1000
HISTSIZE=1000
HOME=/home/ejr
HOSTNAME=hobbes.raycomm.com
HOSTTYPE=i386
IFS=
LINES=24
LOGNAME=ejr
MAIL=/var/spool/mail/ejr
MAILCHECK=60
OLDPWD=/home/ejr/src/rpm-2.5.1
OPTERR=1
OPTIND=1
OSTYPE=Linux
PATH=/usr/local/bin:/bin:/usr/bin:/usr/
→ X11R6/bin:/home/ejr/bin
PPID=1943
PS1=[u@h W]$
PS2=>
PS4=+
PWD=/home/ejr
SHELL=/bin/bash
SHLVL=3
TERM=vt220
UID=500
USER=ejr
USERNAME=
_=cd
[ejr@hobbes ejr]$
|
As you’re going through these steps, you might check out the sidebar Variables in Your Environment You Shouldn’t Touch in this section for a list of variables you should leave alone. Then, in the next section, check out Variables You Can Mess With to find ones you can change.
set
At the shell prompt, type set. You’ll see a list of the current environment and shell variables, as shown in Code Listing 8.1. Some of the variables may look familiar to you (such as the ones showing your shell or user name), while others are likely to be more cryptic (such as the line showing the last command you ran, in this case, _=cd).
setenv
At the shell prompt, type setenv. As Code Listing 8.2 shows, the preconfigured variables will closely resemble the environment variables that bash or ksh offer.
xmission> setenv
HOME=/home/users/e/ejray
PATH=/usr/local/bin:/usr/local/bin/X11:/
→ usr/openwin/bin:/usr/bin:/usr/ucb:/usr/.
LOGNAME=ejray
HZ=100
TERM=vt100
TZ=MST7MDT
SHELL=/usr/bin/csh
MAIL=/var/mail/ejray
PWD=/home/users/e/ejray
USER=ejray
EDITOR=pico -t
OPENWINHOME=/usr/openwin
MANPATH=/usr/man:/usr/local/man:/usr/
→ openwin/man
LD_LIBRARY_PATH=/usr/local/lib:/usr/
→ openwin/lib
PAGER=more
xmission>
|
✓ Tips
If you do as we often do and try to use show to show the environment variables (“showing” the variables seems logical, right?), you might get a weird question about the standard mail directories and the MH mailer. Just press to return to your shell prompt.
If the list of environment variables is long, you can pipe set or setenv to more so that you can read the variables one screen at a time. Try set | sort | more or setenv | sort | more. See Chapter 1 for a reminder about piping commands.
Variables in Your Environment You Shouldn’t TouchBefore you go running off and changing your environment, note that there are some things you should really leave alone. These variables that the shell automatically sets affect how your Unix system works (or doesn’t work, if you try to change some of these variables!). Some of these cannot be changed, but some can, with unpredictable results. When in doubt, don’t. See the sidebar Variables You Can Mess With in the following section for a list of variables you can change.
|