I can put this in /etc/environment and all users will have it:


As I understand it, /etc/environment sets initial environment variables, then .profile, .bashrc and similar happen later.

This results in something like

#> echo $PATH

As it happens, /opt/my/bin and the files within it are not owned by root but by other intermediate-level administrators. On a shared system this opens the door to exploits if a sub-root administrator goes rogue, or is somehow tricked into pushing out a malicious (or vulnerable) file whose name clashes with a system tool.

As part of a defence-in-depth strategy it would seem a sensible precaution to have /opt/my/bin come to the right of everything else. (Paranoid users and script authors will type /sbin/foo <args> but let's not rely on that.)

Can I include a directory in PATH in such a way that

a) all users have it, including newly-created users, without pushing out individual .bashrc (or similar) files to them, and

b) takes effect after PATH has been set to include /sbin, /bin, and friends?

  • use /etc/profile – Ipor Sircer Nov 21 '16 at 17:13
  • Ah right. Want to make that an actual answer? – spraff Nov 21 '16 at 17:26

use /etc/profile or /etc/profile.d/ folder

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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