Create Delete And Modify Local Groups And Group Memberships

General Information

Local group management.

Groups config file

  • /etc/group

See what groups a user is a part of (two methods)

id student
groups student

See what members are apart of the group “class1”

getent group class1
groupmems -l -g class1

Create new group

groupadd class1
  • Other options
    • -g ⇒ specify a group id
    • -r ⇒ create a system group

Set primary group (-g) for the user “student” to “class1”

usermod -g class1 student

Append (-a) supplementary group(-G) for the user “student”

usermod -aG class2 student

Change group name to “class5” from “class1”

groupmod -n class5 class1

Delete group

groupdel class5
  • Note: Cannot delete a user's primary group

  • linux_wiki/create_delete_and_modify_local_groups_and_group_memberships.txt
  • Last modified: 2019/05/25 23:50
  • (external edit)