:What is the commandline to add new directories to a particular users
:PATH variable? I really hate to keep doing it with _jot_.
There isn't a set way. There can't be, really, considering all the
different ways to change the path.
init process: must configure /etc/default/login
other daemons: must configure /etc/default/login or /etc/profile as
/etc/rc*.d/* are /sbin/sh scripts. However, if you've added any of your
own startup scripts, then you must configure the places appropriate for
whatever shells you use for those scripts.
global /sbin/sh change: must configure /etc/profile unless you've
editted /etc/profile to '.' other scripts in which case any of them can
be editted. Or every time you create a user account, add a ~/.profile
file which either is a link to a global configuration file or is
read-only to the users and sources a global configuration file. Oh,
you could also have configured /etc/default/login .
global /sbin/ksh change: as for /sbin/sh unless you've editted
/etc/profile to set the ENV variable to point to a global setup file in
which case that file can be changed. The same tricks as for ~/.profile
can be played with ENV. You could also configure /etc/default/login .
global /sbin/csh change: edit any of /etc/cshrc or /etc/.login or
/etc/csh.cshrc unless you've editted one of those to 'source' other
scripts in which case any of them can be editted. Or every time you
create a user account add a ~/.login or ~/.cshrc file which is either a
link to a global configuration file or is read-only to the user and
sources a global configuration file. You could also have configured
Single-user /sbin/sh change: edit ~/.profile unless of course of you
have written /etc/profile or all the ~/.profiles to look for a file
such as ~/.PATH (arbitrary file name) and '.' that file. Mind you, you
could also configure any of the files noted for the global /sbin/sh
change to special-case on the userid ('id') and make per-user changes
Single-user /sbin/ksh change: as for /sbin/sh unless you've set ENV
somewhere along the way (possibly in ~/.profile) in which case you can
edit the ENV file. Mind you if you let users edit their ~/.profile they
might change the ENV value so you really need to examine their
~/.profile to find out what they are using instead. Unless, that is, in
/etc/profile you test to see which shell is being used and if it is
ksh, you set the ENV variable to be read-only [an operation /etc/sh
cannot do] so that you don't have to worry about that possibility. And
like for /sbin/sh you could do the per-user sort of changes in the
global /sbin/ksh setup, keying on 'id'.
Single-user /sbin/csh change: edit ~/.login or ~/.cshrc unless you have
written /etc/cshrc or /etc/.login or /etc/csh.cshrc to 'source' a file
such as ~/.PATH (arbitrary file name). Unless you do per-user changes
in one of the global /sbin/csh setup files, keying on 'id'.
And these instructions don't even cover tcsh or bash or zsh.
All these possibilities and you are looking for a single command line
tool that can handle all of them? Did you need it to automatically
figure out which method you wanted used, or would a series of
command-line options be good enough?
What I suggest is that you pick one of these methods and write your own
shell script to make the kind of change you want. For example your
script might grep for PATH to discover whether there is an existing
line or not, effect the change using 'ed' with a 'hereis' script if so,
and emitting an appropriate completely new PATH into the file if there
was no PATH before. And initializing the configuration file if it
didn't exist at all.
Watch out for the difference between the csh/tcsh 'setenv' of PATH
compared to the sh/ksh PATH=... export PATH format. Some of the initial
system accounts use /sbin/sh as their shell and some of them use
/sbin/csh as their shell so be careful.
Me, I took the facist position that "All users will be given ksh as
their shell. They are free to set up their accounts to automatically
invoke any other shell from their .profile, but user support for other
shells will not be provided, nor will global configuration files
for other shells be kept up to date."
Mind you I also expect users to be able to edit their -own- PATH
variables if they have special needs. I take care of the global
ksh PATH configuration... which has grown far too complex for
a simple tool. When a new application is added, often other
per-package variables need to be created as well as just adding
the directory onto the PATH.
millihamlet: the average coherency of prose created by a single monkey
typing randomly on a keyboard. Usenet postings may be rated in mHl.