After you’ve poked around in your environment, you might determine that you want to set a variable that’s currently not available or change one to make it better meet your needs. In general, you won’t randomly specify variables; you’ll do it because a certain program requires a specific variable in order to run.
Variables You Can Mess WithThe following table includes some of the variables you can safely change. Keep in mind that the shell itself might not use a specific variable, like NNTPSERVER, while programs running under the shell might. Sometimes shells assign default variables, while in other cases you’ll have to manually set the value.
|
[ejr@hobbes ejr]$ → NNTPSERVER=news.xmission.com [ejr@hobbes ejr]$ export NNTPSERVER [ejr@hobbes ejr]$ echo $NNTPSERVER news.xmission.com [ejr@hobbes ejr]$ |
Fill in Your bash System Configuration Files_________________________________________________________________________ _________________________________________________________________________ _________________________________________________________________________ _________________________________________________________________________ _________________________________________________________________________ _________________________________________________________________________ Fill in Your zsh System Configuration Files _________________________________________________________________________ _________________________________________________________________________ _________________________________________________________________________ _________________________________________________________________________ _________________________________________________________________________ _________________________________________________________________________ _________________________________________________________________________ _________________________________________________________________________ |
By following the steps in this section, you can add or change environment variables for the current session. As Code Listing 8.3 shows, for example, you can specify a news server environment variable (called NNTPSERVER)that some Usenet news readers require to access the news (nntp) server.
1. | NNTPSERVER=news.xmission.com At the shell prompt, type the name of the variable (in this case, NNTPSERVER), followed by = and the value you want for the variable (here, news.xmission.com), as shown in Code Listing 8.3. In this step, you’re setting up the variable and its value and making it available to all programs and scripts that run in the current shell session. If the value contains spaces or special characters, put the value in quotes. |
2. | export NNTPSERVER Type export followed by the name of the variable. By exporting the variable, you make it available to all programs and scripts that run in the current shell session (again, Code Listing 8.3). Until it is exported, it is a shell variable, which will not be available to other processes that this shell starts. |
3. | echo $NNTPSERVER Optionally, type echo followed by a $ and the name of the variable to have the shell tell you what the variable is set to. |
✓ Tip
In bash, ksh, or zsh, save a step by typing export NNTPSERVER=news.xmission.com.
1. | setenv NNTPSERVER news.xmission.com Type setenv followed by the name of the variable, a space, and the value of the variable. In this step, you’re setting up the variable and its value and making the environment variable available to all programs and scripts that run in the current shell session (Code Listing 8.4). Code Listing 8.4. The process for the csh shell is similar to the process for the bash and ksh shells.
| |
2. |
✓ Tips
If you want to change or add to your variables so that the new settings exist from session to session, use the instructions for changing the environment variables in your configuration files, as described throughout the rest of this chapter.
Find out more about news readers in Chapter 12.