The instructions in How do I set PATH variables for all users on a server? work to set the PATH for all 'normal' users. However, if I do sudo -s
and then printenv PATH
the updated path is not shown. I've taken a look at for example Setting TeX Live path for root, but this does not seem to make sense to me, perhaps as I'm from a Windows background. Is there any way to set the truly system-wide path, such that the entries are inherited by absolutely every process running on the system?
Ubuntu – Setting the PATH so it applies to all users, including root/sudo
environment-variablessudo
Related Question
- Ubuntu – How to set PATH variables for all users on a server
- Ubuntu – Setting TeX Live path for root
- Ubuntu – Difference between launching an application from a keyboard shortcut vs the terminal
- Ubuntu – Add path to PATH environment variable for www-data
- Ubuntu – Do terminal tabs correspond to different shells
Best Answer
Update:
Setting global environment variables should still be performed in
/etc/environment
, but as you pointed out, usingsudo -s
has the effect of these variables are "vanished".The reason for that is
sudo
has a policy of resetting the Environment and setting a secure path. It is enabled by default:Thus whatever is set in the
/etc/environment
for the path is overridden bysudo
.The manual page for
sudoers
states:As a workaround, you can use
sudo su
that will provide a shell with root privileges but containing the right PATH.Original Answer
You should set it in
/etc/environment
.Try
sudo YOUR_TEXT_EDITOR /etc/environment
(make sure to create a backup first).For more information: EnvironmentVariables