CentOS8/Linux:用戶組設置密碼和刪除密碼
一、建立用戶組和刪除:horse
[root@test ~]# groupadd horse
[root@test ~]# groupdel horse
二、用戶組的密碼管理
1、gpasswd基礎知識
[root@test ~]# gpasswd -h
Usage: gpasswd [option] GROUP
Options:
-a, --add USER add USER to GROUP
-d, --delete USER remove USER from GROUP
-h, --help display this help message and exit
-Q, --root CHROOT_DIR directory to chroot into
-r, --delete-password remove the GROUP's password
-R, --restrict restrict access to GROUP to its members
-M, --members USER,... set the list of members of GROUP
-A, --administrators ADMIN,...
set the list of administrators for GROUP
Except for the -A and -M options, the options cannot be combined.
[root@test ~]#
2、為用戶組horse設置密碼:
[root@test ~]# gpasswd horse
Changing the password for group horse
New Password:
Re-enter new password:
[root@test ~]#
3、為用戶組horse刪除密碼:
[root@test ~]# gpasswd -r horse
三、用戶組的用戶管理
1、gpasswd基礎知識
[root@test ~]# gpasswd -h
Usage: gpasswd [option] GROUP
Options:
-a, --add USER add USER to GROUP
-d, --delete USER remove USER from GROUP
-h, --help display this help message and exit
-Q, --root CHROOT_DIR directory to chroot into
-r, --delete-password remove the GROUP's password
-R, --restrict restrict access to GROUP to its members
-M, --members USER,... set the list of members of GROUP
-A, --administrators ADMIN,...
set the list of administrators for GROUP
Except for the -A and -M options, the options cannot be combined.
[root@test ~]#
2、為用戶組horse添加用戶
[root@test ~]# gpasswd -a root horse #為用戶組horse添加用戶root
Adding user root to group horse
[root@test ~]# gpasswd -a laohu horse #為用戶組horse添加用戶laohu
Adding user laohu to group horse
[root@test ~]#
3、為用戶組horse刪除用戶
[root@test ~]# gpasswd -d root horse #為用戶組horse刪除用戶root
Removing user root from group horse
[root@test ~]# gpasswd -d laohu horse #為用戶組horse刪除用戶laohu
Removing user laohu from group horse
[root@test ~]#
