To create persistent environment variables, I add the script file to /etc/profile.d directory, for example:
# my script export MY_VAR=var_value
This works properly for current user:
alex@alex-64:~$ echo $MY_VAR var_value
Now I need the same environment variables for the root user, but /etc/profile.d script doesn't work for root:
alex@alex-64:~$ echo $MY_VAR var_value alex@alex-64:~$ sudo su root@alex-64:/home/alex# echo $MY_VAR root@alex-64:/home/alex#
How can I set the same variables for the root?
sudo
is very related. (But it is not a duplicate because this question is about how to customize root's own environment.) – Eliah Kagan Apr 10 '15 at 17:47