I have a fair amount of scripts I've written over the years as well as some compiled programs that I want to be accessible to everyone on the system. I used to put them in /usr/local/bin, but MX uses that dir now so I made another bin under /usr/local/. I modified /etc/profile to add my new bin dir & thought that would suffice. NOPE. Worked fine for console logins, but for managed sessions (XFCE, Enlightenment. etc.) the $PATH was clobbered; back to some default value, I suspect by XDG_SOMETHING_OR_OTHER. I noticed that /etc/profile sources /etc/bash.bashrc (which exists on MX systems) so out of desperation, I copied & modified the PATH definitions there. Wonder of wondes, it worked! Both for console logins & managed sessions. Somewhere between /etc/profile & /etc/bash.bashrc you $PATH gets mutilated. I can't tell you how, by what, or WHY. If you know, please share.
TLDR:
To alter $PATH system-wide on MX, copy the PATH definitions from /etc/profile to /etc/bash.bashrc & make your modifications there. Make sure to put them AFTER the interactive check ([ -z "$PS1" ] && return). Of course, this is bash specific. zsh & other shell users, YMMV.
how to alter $PATH system-wide on MX
Re: how to alter $PATH system-wide on MX
As you say, this does work but it's bash specific. And even worse, it doesn't work for apps that are started not from within a bash terminal (or generally via a bash shell). I used various more or less reliable workarounds over the years until I found that editing /etc/environment did the job (and I now use/edit that file for all systemwide environment variables). I think (but am not sure) this already worked for MX21. It certainly works for MX23. But as ever YMMV.
Frugal installs on Lenovo ThinkPad L14 Ryzen 5 4650U/24GB * HP Pavilion Ryzen 3 3300U/16GB * Toshiba R950 i5-3340M/12GB
I have a reservation... What do you mean it's not in the COMPUTER!
I have a reservation... What do you mean it's not in the COMPUTER!
Re: how to alter $PATH system-wide on MX
That is a valid point, thomasl.
I've also discovered /etc/bash.bashrc PATHs override /etc/skel/.profile which adds ~/bin if it exists, so you need to be sure to put ${HOME}/bin: in /etc/bash.bashrc if you use that method.
One advantage of using /etc/bash.bashrc over /etc/environment is you can use different PATHs for root & non-root users. I want my bin at the start of non-root users but at the end of root's PATH. Don't think you can do that in /etc/environment, although you could easily set root's path absolutely in its resource files.
The /etc/bash.bashrc method suites me fine since my bin is ~98% perl/bash scripts, but I'm going to experiment & see which I like better. I'd still like to know what buggers the path set in /etc/profile though.
I've also discovered /etc/bash.bashrc PATHs override /etc/skel/.profile which adds ~/bin if it exists, so you need to be sure to put ${HOME}/bin: in /etc/bash.bashrc if you use that method.
One advantage of using /etc/bash.bashrc over /etc/environment is you can use different PATHs for root & non-root users. I want my bin at the start of non-root users but at the end of root's PATH. Don't think you can do that in /etc/environment, although you could easily set root's path absolutely in its resource files.
The /etc/bash.bashrc method suites me fine since my bin is ~98% perl/bash scripts, but I'm going to experiment & see which I like better. I'd still like to know what buggers the path set in /etc/profile though.