[COLUG] Best place for modifying path

Rick Troth rmt at casita.net
Wed Apr 18 19:22:25 EDT 2007


Yep ... /etc/profile is your best candidate.

I avoid putting explicit environmental changes in the various
RC files.  (eg: /etc/bash.bashrc)  If you set the path there,
then it can get blown away when a sub-shell is invoked.  If you
append or prepend,  you still risk un-scalable growth of the string
(as well as placement on the wrong end from what was intended).

Use /etc/profile,  but take two big extra steps:  C-shell and GUI

Linux has the most sophisticated ways of doing these things.
But avoid a Linux-centric solution.  (What if you happen to use
MacOS at some point?  Or maybe your employer throws a Windoze box
at you and you have to resort to CYGWIN?  Be prepared.)

In my previous life,  we had a need to change the path for all users.
Turns out that /etc/profile only works for Bourne-compliant shells
(eg: BASH, ZSH, ASH, PDKSH, Unix /bin/sh and friends)  and not for
C-shell complaint shells (eg: TCSH and Unix 'csh').  But with help
from a co-worker who was C-shell savvy,  I was able.  I forget now
excactly how we did it,  but it involved hacking the C-shell profile
such that it ran through the Bourne startup,  or at least part of it,
and then got back into its own mode.  Worked.  Covered all TTY sign-ons.

Then there is another point:  GUI sign-on.
If you can get a hook into KDE or Gnome to source /etc/profile,
I strongly recommend it.  Once the desktop has inheritted settings
established in /etc/profile,  all shells launched from it will also
get those vars.

So if you hook the C-shell startup
and you hook the GUI session initialization
then you are covered even when users change shells.
This is good!

-- R;



More information about the colug432 mailing list