Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
If it's just a couple of binaries you want people to have access to, you can just symlink them to /usr/local/bin without altering environment variables. – jordanm Oct 8 '12 at 6:53
Symlinks does not work because the files in /opt/my-program/bin use some shell script like cd $(basedir "$0"). Symlinks cause $0 changes. – user955091 Oct 8 '12 at 7:02
@user955091 I'd consider that a bug in the program. The standard technique is to look at the symlink target in such a case, precisely so that you can symlink the program in /usr/local/bin or ~/bin. – Gilles Oct 8 '12 at 22:56
Why not remove the assignment of PATH in /etc/profile (at least for non-root users)? – Gilles Oct 8 '12 at 22:57

The /etc/login.defs file contains a default path as follows:

ENV_SUPATH      PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
ENV_PATH        PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games

Some of the variables are moving to the pam modules, but the /bin/login still has it's config file independent of users' shell.

share|improve this 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

share|improve this answer
/etc/profile is not executed by non-login shell – user955091 Oct 8 '12 at 8:06
I know - but bash.bashrc is which is why the path change should be added there and then make /etc/profile source /etc/bash.bashrc to make the changes for login shells as well. – didster Oct 8 '12 at 8:14

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.