Removing Users From Groups In CentOS / RHEL / Fedora In CLI
So many websites will explain how to add a user to a group, but if i need to remove a user from a group in the CLI how to do it, This is how..
If you don't know how to add a user to a group read the following tutorial.
http://tiny.cc/W0bzu
How to remove a user from a group.
I have not found any commands for this so I'll teach a manual method.
Assume there is a group call "group1" and there are three members in the group call "user1", "user2", "user3"
I want to remove "user2" from "group1"
1. The group details will be stored under two files call "group" and another call "gshadow", We'll examine the files first
# cat /etc/group
You'll find a line as follows
group1:x:503:user1,user2,user3
# cat /etc/gshadow
You'll find a line as follows
group1:!::user1,user2,user3
2. Now what we have to do is, manually remove "user2" from the "group1", Give the following command.
# vigr
The above command will open "/etc/group" file in VI text editor.
3. Use the down arrow key and go up to "group1:x:503:user1,user2,user3" line and press " i " to go to insert mode, and delete "user2" from the line, Now it'll look like this.
group1:x:503:user1,user3
Then press "esc" and type" :wq " to save and exit the file. It'll ask a question as follows,
You are using shadow groups on this system.
Would you like to edit /etc/gshadow now [y/n]?
Press " y " and press "enter"
Now it'll open "/etc/gshadow" file in VI text editor.
Use the down arrow key and go up to "group1:!::user1,user2,user3" line and press " i " to go to insert mode, and delete "user2" from the line, Now it'll look like this.
group1:!::user1,user3
Then press "esc" and type" :wq " to save and exit the file.
4. That's it, now the "user2" is removed from "group1"
This is another way to do it but you want be able to completely remove a user from the groups he/she belong to.
http://tiny.cc/zMm7x
Showing posts with label Removing Users From Groups. Show all posts
Showing posts with label Removing Users From Groups. Show all posts
Sunday, March 2, 2008
Removing Users From Groups In CentOS / RHEL / Fedora
Posted by
jyrxs
at
4:05 PM
Labels: CentOS, Fedora, Linux Commands, Redhat, Removing Users From Groups
Subscribe to:
Posts (Atom)