0

I came across this issue as I wanted to extend the PATH variable for all users by adding another directory at the end of PATH in /etc/environment.

Neither opening a new shell nor a fresh login did show the extended PATH.

I found that the protections on /etc/environment were set to

-rw-r--r-- 1 root root 588 May 13 12:08 /etc/environment

Setting /etc/environment to be executable fixed this for me.

1 Answers1

6

The file /etc/environment is not intended to be executed as a program but read or sourced so it does not need the executable privilege and should not have one.

For interactive shells the file should normally be read by the PAM system. For example on Ubuntu 22.04 in WSL2 it should be read by login and sshd. Check the files in /etc/pam.d/. If you did not test login on the text console or over SSH, test it.

Better way of changing the environment variables for all users is adding an .sh file to /etc/profile.d/. This way you can separate your configuration from the distribution's system files and prevent possible problems during upgrades.

Some more details are in this question: Setting PATH variable in /etc/environment vs .profile