Add User Group Command Groupadd
Syntax: Groupadd [-G GID] [-r] Group_name
-G: Specify user group ID
-r: Specify user group as System user group
Example:
[[email protected] ~]# groupadd testgrp[[email protected] ~]# grep testgrp/etc/group/etc/gshadow/etc/group:testgrp:x : 503:/etc/gshadow:testgrp:!::
change user group Parameters command Groupmod
Syntax: groupmod [-G GID] [-N group_new_name]group_old_name
-G: Change user group ID
-N: Change user group name
Example:
[[email protected] ~]# groupmod-g 504-ngroup1 testgrp[[email protected] ~]# grep group1/etc/group/etc/gshadow/etc/group : group1:x:504:/etc/gshadow:group1:!::
Delete User Group command Groupdel
Syntax: Groupdel [group_name]
Example:
[Email protected] ~]# Groupdel group1
Note: If this user group is the initial user group of a user, the user group cannot be deleted, but the user group can be deleted by changing the user's initial user group ID or by deleting the user.
[Email protected] ~]# Groupdel whxgroupdel:cannot Remove the primary groupof user ' whx '
User group Administrator function gpasswd
For root user actions:
Syntax: GPASSWD group_name
gpasswd [-A user_name1,...] [-M user_name2,...] Group_name
GPASSWD [-RR] Group_name
Set a password for a user group when no parameters are added
-A: Specify the administrative user for the user group
-M: adding user Group members
-r: Delete user group password
-R: Invalid user group password bar
For user group Administrator actions:
Syntax: gpasswd [-AD] user_name Group_name
-A: Add user group members
-D: Delete user Group members
Example:
[[email protected] ~]# groupadd testgrp[[email protected] ~]# gpasswd Testgrpchanging the password for group testgrpnew password:re-enter new password:[[email protected] ~]# gpasswd -A xx testgrp[[email Protected] ~]# grep testgrp /etc/group/etc/gshadow/etc/group:testgrp:x:503:/etc/gshadow: testgrp:$1$mxatf/sr$nudqk9ytidegnk0qkjybh0:xx:[[email protected] ~]# su xx[[email protected] root]$ cd ~[[email protected] ~]$ iduid=501 (XX) gid=501 (XX) groups=501 (XX), (WHX) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023[[email protected] ~]$ gpasswd -a xx testgrpadding user xx to group testgrp[[ email protected] ~]$ gpasswd -a whx tesetgrpgpasswd: group ' Tesetgrp ' does not exist in/etc/group[[email protected] ~]$ gpasswd -a whx testgrpadding user whx to group testgrp[[email protected] ~]$ grep testgrp /etc/ Grouptestgrp:x:503:xx,whx
This article is from the "Dark Shun" blog, please make sure to keep this source http://mjal01.blog.51cto.com/12140495/1971080
Linux User Group Management