Your first step in modifying or adding bash environment variables in your configuration files is to look at the configuration files, which show you the variables that have been defined. As Code Listing 8.10 shows, you do this using more or the editor of your choice.
Remember that configuration files run in a specific order:
Systemwide configuration files (such as /etc/profile) run first upon log in.
Configuration files specific to your Unix account (such as ~/.bash_profile or ~/.profile) run next if they’re available.
1. | more ~/.bash* ~/.profile → /etc/bash* /etc/profile At the shell prompt, type more followed by each of the possible system configuration filenames to view your configuration files. If you don’t have all of the files mentioned here, don’t worry. Just make note of the ones you do have. Code Listing 8.10 shows an example of what you might see. Notice that some of the lines will reference other files, like the ENV=$HOME/.bashrc line that references the .bashrc file, containing other configuration settings. Code Listing 8.10. Your configuration files set up your environment variables and other features of your Unix experience.
| |
2. | Write down, for your reference, the system configuration files and the order in which they’re run. (Remember, settings in the last file run override all previous ones.) Our system configuration files include
|
✓ Tips
The bash shell sometimes daisychains configuration files together, referencing one from the previous one. Be careful to preserve the references and sequence as you edit your configuration files, or you might end up with unexpected results.
All lines that start with # are comments, which contain notes to help you better understand the files. Comments don’t actually do anything, but they help you see what each section in the file does.
The techie term (that you’ll likely see in these files) for executing a configuration file or a script is to source it. That is, when you log in, your .profile may source .kshrc.
18.221.112.220