LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to add a user to a group with a command without removing from another group? (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-add-a-user-to-a-group-with-a-command-without-removing-from-another-group-4175609694/)

erik2282 07-12-2017 09:29 AM

How to add a user to a group with a command without removing from another group?
 
I am studying for the RHCSA and I'm on chapter 3 of the Asghar Ghori book. Anyway, one of the exercises has you add a user to a group. Easy enough, right?

Code:

# usermod -G /path/groupfolder user100
But I noticed that when I ran the groups command with user100, the group that he was a part of before, he was no longer a part of, he was only part of the new group I added him to. I know I can just edit /etc/group and add the info in there, but how do I use this command to not replace his original group he's in but add an additional group to user100?

I hope my question is clear. Let me know if you need further clarification.

Also I've read the man page for usermod, and unless I'm not understanding something, it doesn't really explain this.

pan64 07-12-2017 09:39 AM

did you check the flag -a?

erik2282 07-12-2017 09:49 AM

Thanks pan, I had read the man page incorrectly on the -a part. I was reading it as use -G instead of -a. Anyway that works, thanks.


All times are GMT -5. The time now is 03:24 PM.