List all environment variables
$printenv
Check a specific environment variable
$echo $[variable name]
Set emporary environment variable
Step 1 : Open ~/.bash_profile
for add new environment variable
$open ~/.bash_profile
Step 2 : Add new environment variable to ~/.bash_profile
export [variable_name]=[variable_value]
Step 3 : Save any changes to ~/.bash_profile
Step 4 : Use the source
to execute the new ~/.bash_profile
$source ~/.bash_profile
Set permanent environment variable
Step 1 : Open ~/.zshrc
for add new environment variable
$open ~/.zshrc
Step 2 : Add new environment variable to ~/.zshrc
export [variable_name]=[variable_value]
Step 3 : Save any changes to ~/.zshrc
Step 4 : Use the source
to execute the new ~/.bash_profile
$source ~/.zshrc
Unset environment variable
Use the unset
command to remove an environment variable
$unset [variable_name]
Top comments (0)