I want to set a environment variable globally for all users in linux.
In order to do that I modified /etc/environment file.
For example at the end of file.
sudo sh -c 'echo "\nmyenv=hello" >> /etc/environment'
After executing this command when in run in the same terminal.
echo $myenv
i'm not getting the value hello.
After typing the below command.
source /etc/environment
I'm able to access the environment variable in command prompt with
echo $myenv
But the problem in this method is if i execute a sh file. Which is accessing the $myenv. I need to again type the command
source /etc/environment in that shell script.
Please let me know what is going wrong here.
Please suggest me what is the approach followed here.
I don't what to logoff and logon or restart my server.
/etc/environmentis parsed bypam_env.