Anyone know how to add a user to a group via SSH in Linux?
If the user already exists you can use 'usermod':
This will add a group to a user as a secondary group. If you want to change the primary group:Code:# usermod -a -G <NewGroup> <UserName>
Code:# usermod -g <Group> <UserName>
Isn't there a way to do this when you create the user also?
Well, when doing that through a GUI you can, so I guess you can from the CLI too...
But I think GUI is different....
You can add them to groups at creation with the useradd command:
Code:# useradd -G {group-name} username
Hehe, the command is nearly the same as the moduser... but instead it's adduser.. funny.
Yeah the GUI is different, but at the back there is the CLI I think... it still executes the same commands... but in a nicer way!
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks