Can’t change global PATH environment in ubuntu 18.04

I tried editing /etc/environment, changed it by removing games and adding my swift installation location, so now it looks like:
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/swift/usr/bin"
That didn’t work (even tried booting).
After searching for a solution, I came to realize that PAM aware applications (I have UsePAM no in my sshd_config, but I tried this anyway) use the file /etc/login.defs.
Went on and changed it, removed the games and added swift (to the su version as well).

ENV_SUPATH      PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/swift/usr/bin
ENV_PATH        PATH=/usr/local/bin:/usr/bin:/bin:/opt/swift/usr/bin

That didn’t help as well.
After rebooting the machine – I still have games in my path, and no swift.
Tried removing /etc/profile/apps-bin-path.sh, my path is still:
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games

Where is games coming from?
Why doesn’t my path change?
I need this variable to be set for both login and non login shells, including non bash shells.

Answer

It is interesting, because I’ve just successfully removed /usr/games and /usr/local/games from the path by removing them from the /etc/environment file (and removing both directories by rm -r games). Ubuntu 18.04.

Attribution
Source : Link , Question Author : iMoses , Answer Author : Alex Fedotov

Leave a Comment