- list all users?
pw usershow -a
- change multiple users to nogroup primary group?
There's a hundred different ways to do this... I would:
foreach u ("list" "of" "users")
pw usermod -n $u -g NewPrimaryGroup
end
You could even get the list of users from a subcommand, like pw groupshow OldGroupName | sed -e "s/.*://" -e "s/,/\ /"
- add secondary/auxiliary groups to multiple users?
Again, a few ways to do this...
If you know the full list of secondary groups that the users should be in:
pw usermod -n UserName -G "Secondary Group List"
If you don't know the full list, or just want to add users to a group:
pw groupmod -n SecondaryGroup -m NewUserName
And removing is similairly
pw groupmod -n SecondaryGroup -d OldUserName
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.
foreach u (`pw groupshow clients | sed -e "s/.*://" -e "s/,/\ /"`)
pw usermod $u -g nogroup
pw groupmod clients -m $u
end
(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)