1. 程式人生 > >Linux中的組管理員-gpasswd

Linux中的組管理員-gpasswd

如果root工作比較忙,沒有時間來管理組,可以交由組管理來進行管理

gpasswd命令是Linux下工作組檔案/etc/group和/etc/gshadow管理工具。

引數說明
無引數:gpasswd給組建立一個密碼,使用者加入該組需要輸入密碼
-a:新增使用者到組;
-d:從組刪除使用者;
-A:指定管理員;
-M:指定組成員和-A的用途差不多;
-r:刪除密碼;
-R:限制使用者登入組,只有組中的成員才可以用newgrp加入該組。

配置例項:
1、給test組建立一個密碼

[[email protected] tmp]# gpasswd test
Changing the password for group test
New Password:
Re-enter new password:

2、新增user1,讓user1來管理test組

[[email protected] tmp]# useradd user1
[[email protected] tmp]# gpasswd -A user1 test

3、建立user2,user3使用者,並且讓user1新增這兩個賬戶到test組中

[[email protected] tmp]# useradd user2
[[email protected] tmp]# useradd user
[[email protected] tmp]# su - user1
[[email protected]
~]$ gpasswd -a user2 test Adding user user2 to group test [[email protected] ~]$ gpasswd -a user3 test Adding user user3 to group test

4、檢視/etc/group檔案進行驗證

[[email protected] ~]# tail -n 10 /etc/group | grep test
test:x:1001:user2,user3