1

Delete every users from a group

view story
linux-howto

http://unix.stackexchange.com – I search a clean way to delete every users from the 'sudo' group. On several distributions the user created during the installation process has sudo rights, I don't want this. I search for an automated method working for (nearly) every situations. Basically, I want to empty a group. To remove every users : GROUP=my_group; for u in $(getent group $GROUP | sed -e 's/^.*:.*:.*://' -e 's/,/ /g'); do echo gpasswd --delete $u $GROUP; done This command line works : 1. if the group doesn't exist 2. if the group is empty 3. if the group contains one user 4. if the group contains several users So (HowTos)