问题重现:
1、查看普通用户身份信息
[test1@localhost ~]$ id
uid=1005(test1) gid=1009(test1) groups=1009(test1) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
2、root将普通用户添加进root组
[root@localhost ~]# gpasswd -a test1 root
Adding user test1 to group root
3、查看普通用户身份信息
[test1@localhost ~]$ id
uid=1005(test1) gid=1009(test1) groups=1009(test1) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
这里可以看到用户的所属组并没有发生变化,自然也不会拥有对应的权限
问题解决办法:
第一个办法:执行newgrp root 命令
[test1@localhost ~]$ newgrp root
[test1@localhost ~]$ id
uid=1005(test1) gid=0(root) groups=0(root),1009(test1) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
可以看到用户所属组变多了,这里也就得到了组权限