Posts Showing and Setting Environment Variables on CentOS7
Post
Cancel

Showing and Setting Environment Variables on CentOS7

For some reason, we set values to Environment variable on our system so that our program can work accordingly. therefore I learn how to show and set environment variables.

To show all the current environment values,

1
env

env

To show particular environment value, for example PATH,

1
echo $PATH

env

To set a custom environment value, for example bulafish=hi and verify,

1
2
export bulafish=hi
echo $bulafish

env

The value is only validate for the current ssh session by using the command above. If you want to set the value permanently, modify /etc/environment, after that, you must logout the current ssh connection and re-login again to make the change take effect.
env

REFERENCES:
https://tw.godaddy.com/help/centos-12295
Environment Variables

This post is licensed under CC BY 4.0 by the author.