
VARIABLE:
There are two types of variables namely:
i) Local Variable (shell variable)
ii) Environment Variable
SHELL VARIABLES:
Shell allows you to define and use variable.
If you want to define a variable a with numerical value 10.
after you log in are called Environment variables or System Variables.
ENVIRONMENT VARIABLES:
Environment variables are set using the syntax:
export VAR=VALUE
or in two lines:
VAR=VALUE
export VAR
Example:
$HOME (for home folder)
$MAIL (directory for incoming mails)
$PATH (path for executables)
$LOGNAME (for username)
$TERM (for terminal-type)
Note:
If you export a variable, or set an alias on the command line, it only stays active for that one bash session. You must put it in your login script for it to stick.
Example:
vim ~/.bashrc
export HISTCONTROL=ignoreboth
(add this line at the end of file, not to repeat command in history)
Note:
set |
display all variables (use less command for pagewise) |
env |
display environment variables |
echo |
a single variable. |





