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 
point, its easy if they are only in one group. Suppose the existing group is 
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 
chgrp $i support support1 

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 
reside in any filesystem and every file has to be changed. Perhaps someone 
can add to this when multiple group names are involved. There may even be a 
way of doing it from the start.


Post a Comment

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