0

We know that modify the shadow files directly using vi isn't a good idea, and so vigr, vipw and visudo were developed to better perform this action. How can I remove a admin from a group? Is it possible to do this without editing gshadow directly?

[root@server230 ~]# gpasswd -A user1 -g linuxadm
[root@server230 ~]# !grep
grep linuxadm /etc/gshadow /etc/group
/etc/gshadow:linuxadm:!:user1:
/etc/group:linuxadm:x:6000:
[root@server230 ~]# gpasswd -d user1 -g linuxadm
Removing user user1 from group linuxadm
gpasswd: user 'user1' is not a member of 'linuxadm'
0

I just find the answer:

[root@server230 ~]# gpasswd -A '' linuxadm
[root@server230 ~]# !grep
grep linuxadm /etc/gshadow /etc/group
/etc/gshadow:linuxadm:!::
/etc/group:linuxadm:x:6000:
  • You could also just do a vim /etc/<file> and remove the username from the line then save the file. – thebtm Sep 28 '17 at 18:55
  • @thebtm I find that is possible to use vigr -s to edit shadow files. – bugsam Sep 28 '17 at 19:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.