Ubuntu – Environment variable vs Shell variable, what’s the difference

bashcommand lineenvironment-variables

Somebody told me that:

BASH isn't an environment variable,
it's a shell variable

What's the difference?

Best Answer

$BASH is a local variable that is valid in the current (bash) shell only.

Environment variables such as $SHELL are valid systemwide. In a current Bash shell, $BASH points to the execution path of bash, whereas $SHELL points to the shell defined as default (which may be of the same value).

For an explanation of environment variables see Environment Variables in Ubuntu Help.

Related Question