-
Add a New Group
groupadd <groupName>
-
Add an Existing User to a Group
- usermod -a -G <groupName> username
- For example, to add user geek to the group admins, use the following command:
- usermod -a -G admins geek
-
Change a User’s Primary Group
usermod -g groupName username
-
View a User’s Group Assignments with numbers
- id userName
- uid=500(howtogeek) gid=500(howtogeek) groups=500(howtogeek), 1093(admins)
-
View a User’s Group Assignments without numbers
groups userName
howtogeek : howtogeek admins
-
View a List of All Groups
-
Add a New User and Assign a Group in One Command
- useradd -g groupName username
- does not create new group
- useradd -G groupName username
- creates new group
-
Add a User to Multiple Groups
- You can easily add a user to more than one group by simply specifying them in a comma-delimited list, as long as you are assigning the secondary groups:
- usermod -a -G ftp,admins,othergroup userName
- .
|
|