0

I have always been thinking about the effective way of managing environment variables in operating systems like Ubuntu, macOS, etc.. I have a couple of questions related to it.

  • Is there a common sense that every single executable software installed on the system should be available system-wide in terms of invocation ? Or executables should be only invoked by shell in default ?

  • I have been seeing exporting shell variable to extend PATH variable method everywhere. But it is only applied in one shell. Because every shell has its own file for initialization. We need to write the same statement in every shell file. For example if I use zsh, I should to do like this:

echo 'export PATH="/path/to/bin:$PATH"' >> ~/.zshrc

  • Those programs which is not in system-wide path, cannot not be invoked directly by another program. I guess it is a kind of isolation between default executables and others to make system path clean. Then we shouldn't manipulate system-wide PATH ?

I may confuse a little bit, sorry for it. But I would really appreciate if you could help me make it clear.

closed as primarily opinion-based by DavidPostill Nov 4 '18 at 7:23

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.

1

Environment and other resource management are typically done by two different personas. The systems administrator will typically setup a system with a set of software and ensure that the configuration of that software is completed for all users. This could include environment variables, resources etc.

Users are the other persona and they are guests on the system and their configurations are like decorating your room. Install the software you want, add or remove PATH entries, add software not on the system. In general, if you want something system wide then /etc is the place where setting would be established. For User specific customization you would do that in your user account with the corresponding config like .profile, or .bashrc for Bash. Every software has their unique configuration structure.

Your administrator persona manages the profiles for all users which users can customize. In most instances as a developer you are one and the same person.

No magic formula really, do what works for you.

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