Linux 用户组

初始群组:创建用户时加入的,在/etc/group中不体现
支援群组:在/etc/group中看到的加入的群组,通过id 或者groups命令可以查看
有效群组:groups命令看到的第一个群组
切换命令:newgrp
eg:
[redhat@localhost ~]$ id redhat
uid=1000(redhat) gid=1000(redhat) groups=1000(redhat),10(wheel) #说明支援群组为wheel 初始群组为redhat
[redhat@localhost ~]$ groups
redhat wheel #有效群组为redhat
[redhat@localhost ~]$ mkdir test1
[redhat@localhost ~]$ ll
total 0
drwxrwxr-x. 2 redhat redhat 6 Jun 28 01:44 test1 #属组为redaht
[redhat@localhost ~]$ newgrp test
Password:
Invalid password. #组密码未知
[redhat@localhost ~]$ sudo gpasswd wheel
Changing the password for group wheel
New Password:
Re-enter new password: #为wheel组设置密码
[redhat@localhost ~]$ newgrp wheel
Password: #修改有效群组为wheel
[redhat@localhost ~]$ mkdir test2
[redhat@localhost ~]$ ll
total 0
drwxrwxr-x. 2 redhat redhat 6 Jun 28 01:44 test1
drwxr-xr-x. 2 redhat wheel 6 Jun 28 01:51 test2 #属组为wheel

posted @ 2017-06-27 23:39  rui_cpu  阅读(238)  评论(0)    收藏  举报