user:!::stu01,stu02
[root@localhost ~]# gpasswd -d stu01 user //将stu01从user组中删除
正在将用户“stu01”从“user”组中删除
[root@localhost ~]# cat /etc/gshadow | tail -1
user:!::stu02 //删除后只剩下stu02用户
[root@localhost ~]# gpasswd -A stu02 user //将stu02设置为管理员
[root@localhost ~]# grep user /etc/gshadow | tail -1
user:!:stu02:stu02 //gshadow文件中,第三个字段为该组的管理员账户,为stu02
[root@localhost ~]#
2,usermod主要是对用户的属性进行更改,可以增加用户成员的所属附加组
只是用usermod的 -a-G选项(-a表示添加,-G指定组,-a -G为新加一个附加组)
命令:usermod -a -G 用户组 用户名
[root@localhost~]# usermod -a -G tech stu02 //为stu02增加一个附加组tech
[root@localhost~]# id stu02
uid=501(stu02) gid=1201(nsd)groups=1201(nsd),200(tech),1204(user)
上一页12 下一页 阅读全文










