Saturday, 7 September 2013

How to delete a user from a group using single command in linux?

I have created a user called 'sam' and he is a member of the group 'webdeveloper'. Currently he is on long leave and I want to remove him from the web developer group without deleting this user.  How can I do this? We will find below.

We can edit /etc/group file and remove the user 'sam' from 'webdeveloper' . But there is also another simple way by using a simple command.

Use below command to remove user 'sam' from group 'webdeveloper' without editing any files.

gpasswd -d sam webdeveloper

The general syntax is :

gpasswd -d user group

No comments:

Post a Comment