Environment Variables
Environment Variables
Environment Variables:
A variable is a temporary storage of data in memory. Stored information is used for customizing the shell
environment and by many system and application processes to function properly.
The value of an environment variable can be passed from current to sub-shell during the execution of a script,
which means value stored in an environment variable is passed from the parent process to the child process.
Some environment variables are defined automatically through system and user startup files at login such as:
- HOSTNAME - stores hostname
- HISTFILE - Define files for storing history of commands
- HOME - Sets the home directory path
- LOGNAME - Stores the login name
- PWD - Stores the current directory location
- SHELL - Holds the absolute path to primary shell file
- echo $PWD
ENVIRONMENT VARIABLES
Set an Unset Variables and View their Values:
-Local and environment variables may be set or unset at the command prompt or
via programs, and their values may be viewed and used as necessary.
-Uppercase letters for naming variables are recommended to avoid any possible
conflicts with existing command, program, file or directory names.
Example:
Define a local variable called VR1:
$- VR1=rhel7
or L=LINUX