-
Notifications
You must be signed in to change notification settings - Fork 0
Linux Environment Variables
Nuno Nogueira edited this page Dec 12, 2022
·
11 revisions
- To view global environment variables use the
env
or theprintenv
command.
- To view local environment variables use the
set
command.
-
Set string value without spaces:
my_var=Linux
-
Set string value with spaces:
my_var="Gnu Linux"
-
Set number value:
my_var=7625
-
Unset Variable:
unset my_var
User-Defined Variables will only be visible in the shell process being used
- To print the variable value just use
echo $VARIABLE
. Example:echo $USER
NOTES:
All global environment variables displayed using the
env
orprintenv
commands appear in theset
command’s output.
env
andprintenv
produce duplicate listings. However, theenv
command has additional functionality thatprintenv
does not have, making it the slightly more powerful command.