Create groups:
To create a group simply run the following command:
groupadd groupnameDelete group:
To delete a group simply run the following command:
groupdel groupnameModify groups and group memberships:
The first objective can be achieved with the groupmod command, whereas the second can be achieved with usermod as explained in the previous post, or with the groupmems command.
Say you want to change the name of a group:
groupmod -n newgroupname oldgroupnameor change the group id :
groupmod -g 1234 groupnameGroup memberships can be changed with the groupmems command. To add users to a group issue the following command:
groupmems -g groupname -a usernameand to delete them from the group:
groupmems -g groupname -d usernameYou can purge a group with the -p switch and the -l switch will list the users belonging to that group, e.g.:
groupmems -g groupname -lThe group file is in /etc/group, but you could also list its contents with the getent command:
getent groupThis commands works for users (passwd or shadow), hosts and a few others, as detailed in the man page.
No comments:
Post a Comment