I would like to add a directory to the $PATH
variable for all users, including users who run byobu
with sudo byobu
.
I am running Ubuntu 22.04 LTS on x86_64.
The desired path is below. Note the presence of cuda-12.3
:
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/local/cuda-12.3/bin
I updated /etc/environment
to include this line:
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/local/cuda-12.3/bin"
That is sufficient to set $PATH
for users and for root.
username:~$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/local/cuda-12.3/bin
$ sudo su
# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/local/cuda-12.3/bin
It is also sufficient to update path when launching byobu
as a regular user.
$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/local/cuda-12.3/bin
The issue occurs when I start sudo byobu
and get the $PATH
.
$ sudo byobu
# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin
Notice that cuda-12.3
is missing, as are other directories.
I tried editing the following locations, but all failed to set $PATH
correctly when running sudo byobu
.
/etc/profile
/usr/share/byobu/profiles
/root/.profile
I have referred to these posts:
PATH
is going to get reset by the default sudoersenv_reset
policy - unless it's added by way ofenv_keep
– steeldriver Oct 26 '23 at 21:57