I need to change group membership for a bunch of users.
How do I
- list all users?
- change multiple users to
nogroup
primary group? - add secondary/auxiliary groups to multiple users?
Basically I need to change all the users that are currently in the clients
group to nogroup
and add clients
as an auxiliary group to them.
Can this be done via shell without individually editing each user?
There's a hundred different ways to do this... I would:
You could even get the list of users from a subcommand, like
pw groupshow OldGroupName | sed -e "s/.*://" -e "s/,/\ /"
Again, a few ways to do this...
If you know the full list of secondary groups that the users should be in:
If you don't know the full list, or just want to add users to a group:
And removing is similairly
(The above snippet is untested, but looks good after 3 seconds of double-checking, also written for
csh
as that's FreeBSD's default shell for users)