How to Add Path to System $PATH for All Users’ Non-Login and Login Shells on Debian

debianenvironment-variablespath

I installed some programs in /opt/my-program/bin, I wanted to add /opt/my-program/bin to system $PATH for all users's non-login shell and login shell. What should I do?

Changing /etc/environment is OK for non-login shell, but it does not work for login shell because Debian's /etc/profile (which will be sourced by login shell) will override the $PATH specified in /etc/environment.

Best Answer

Make /etc/profile source /etc/bash.bashrc by adding [ -f /etc/bash.bashrc ] && . /etc/bash.bashrc to the end of /etc/profile, then add your path changes to /etc/bash.bashrc with PATH=$PATH:/some/other/path

Related Question