Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
There are different ways of removing users from a group.
Command usermod
Using option -g, --gid GROUP will set the primary group of user to "groupname",
Using option -G, --groups GROUP1[,GROUP2,...[,GROUPN]]] it will put suplementary groups to the user, if the user is currently a member of a group which is not listed, the user will be removed from the group.
or simply by editing the file: /etc/group which specifies the groups and its users
e , and that will make the person be in two groups only,his own private group and the group you just specified.If there are more than just two groups then use the -a command and list the groups you want the person to ONLY be in.
Quote:
#usermod -a -G group1,group2,group3,group4 username
e , and that will make the person be in two groups only,his own private group and the group you just specified.If there are more than just two groups then use the -a command and list the groups you want the person to ONLY be in.
It will remove all groups for the user, except the one specified in the command. Its not a good option, becuase user may have many other important secondary groups.
So, instead use deluser command as:
Code:
~# deluser <username> <groupname>
OR
~$ sudo deluser <username> <groupname>
No. It's not at all recommended to edit configuration files directly when you have an option of direct commands to do this.
@mangesh_ram:
Don't directly edit the config. file. You have certain commands to edit the groups of a user, so simply use those command.
I wonder why you say so? Does the system keep track of users in groups in other files or it is only /etc/group file? If it is only file that keeps track of those supplementary groups than it is no harm if you edit it, but sure edit it correctly, because if I am not mistaken the commands do exactly that. Sure I am speaking of local users and local groups not for AAA through network.
@DinoFly:
You are right, there's no harm if file is edited correctly. But there're chances of mistakes, and why one should edit the file directly when he has commands to do so? Commands were created for this purpose and we should stick to commands.
It will remove all groups for the user, except the one specified in the command. Its not a good option, becuase user may have many other important secondary groups.
I dont think you took the time to read my post in its entirety,feel free to do so at your convenience.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.