Share a .profile amongst multiple users

Associate
Joined
12 Oct 2005
Posts
1,511
Location
Surrey
I have a sizeable number of KSH .profile variables I need multiple users within a group to have in their shells.

I can't set it as a system-wide set of variables as it is only the users in the partciular group who should have the variables.

Rather than manually editing each profile - how can I do this elegantly?
 
You've got /etc/default/login and /etc/profile you can use for this kinda thing.

Or just deploy the same .profile out to everyone's directory with something like:

Code:
for user in `ls -la /home | awk '{print $3}'` 
do
cp .profile /home/$user
chown -r  $user:<whatever group> /home/$user
done
Where username is derrived from ls-ing the /home directory and using awk to select the second column from this ls output:

Code:
1            2  3            4          5       etc.....
drwxr-xr-x   3 someuser     staff        512 Nov  3  2008 someuser
 
Found it easiest to just distribute to the users in a group through some scripting.

Great- thanks :)
 
Currently have a script which distributes a file dependent on those users in a certain group using a cat/awk etc of /etc/group
 
You could have something like this in /etc/profile (in pseudo):

if userid=500 then
source /etc/special_bits
./special_bits
some funky command
fi

Copying things over is a bit of a nightmare. I suggest you stick to a single /etc/profile rather than start making ad-hoc ones. :)
 
Back
Top Bottom