(Please excuse my English)
I installed WSL Ubuntu 24.04 on my Windows machine, and edited /etc/environment
like below to change the system-wide $PATH.
- Before
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin"
- After
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/mybin"
However, Only the root user' $PATH changed, and the default user's $PATH did not changed at all, like below. ('us' is the default username of WSL Ubuntu and 'SERVER' is my Windows machine name)
us@SERVER:~$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib:/snap/bin
us@SERVER:~$ su root
Password:
root@SERVER:/home/us# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/mybin
Considering that the default user's $PATH contains the string usr/lib/wsl/lib
, it seems that WSL Ubuntu sets the default user's $PATH somewhere else.
How can I modify the default user's $PATH in WSL Ubuntu?