Wednesday, October 9, 2013

Primary group change for all users in AIX

WWW.UNIXBABUFORUM.INI need to change most of my users to have a different primary group on their ID on AIX 5.3. What script can be creted for this?

WWW.UNIXBABUFORUM.INThe easiest way is to run a script to capture all the users to a 
file - lsuser | ALL > /tmp/userlist | awk '{ print $1, $2,$4}` will capture 
all users, 
their userids and groups. Now edit the file to remove unwanted users. From 
this 
point, its easy if they are only in one group. Suppose the existing group is 
support 
and you are changing it to support1, then run the following 
cat /tmp/usrlist | awk '{ print $1 }' > /tmp/newlist (this creates a list 
of users only) 
D=`cat /tmp/newlist` 
for i in $D 
do 
chgrp $i support support1 
done 

This changes the groups but does not touch any of the file ownership that 
any user 
has created. Finding and changing these files is more of a challenge as they 
could 
reside in any filesystem and every file has to be changed. Perhaps someone 
else 
can add to this when multiple group names are involved. There may even be a 
better 
way of doing it from the start.

0 comments:

Post a Comment

 
Design by BABU | Dedicated to grandfather | welcome to BABU-UNIX-FORUM