This article was co-authored by wikiHow staff writer, Nicole Levine, MFA. Nicole Levine is a Technology Writer and Editor for wikiHow. She has more than 20 years of experience creating technical documentation and leading support teams at major web hosting and software companies. Nicole also holds an MFA in Creative Writing from Portland State University and teaches composition, fiction-writing, and zine-making at various institutions.
This article has been viewed 4,877 times.
Learn more...
In Linux, groups organize users by grouping certain access levels to files and directories. Every user is a member of a primary group by default and can also be added to secondary groups with additional permissions. If a set of Linux users all need the same permissions to specific files and directories, you can add them to a group and set permissions for that group as a whole instead of for each individual user. This wikiHow article will teach you how to add a user to a group, change a user's primary group, and take care of other group-related administrative tasks on a Linux server or workstation.
Things You Should Know
- Use the command sudo usermod -a -G <groupname> <username> to add a Linux user to a group.
- To change a user's primary group, use sudo usermod -g <groupname> <username>.
- To remove a user from a group, use sudo gpasswd -d <groupname> <username>.
Steps
Expert Q&A
Tips
-
While you can technically edit /etc/group by opening it with a text editor like Nano or Vim, it's best to use the vigr command to lock the file during the editing process.[6]Thanks
-
When viewing a file or directory's permissions, the second set of characters (after the first character, which is always d for a directory or - for a regular file) indicate the group's permissions. For example, if a file's permissions are -rwxrw-rw- and the group is developers, the developers group has rw permissions (read and write).Thanks
References
- ↑ https://man7.org/linux/man-pages/man8/usermod.8.html
- ↑ https://manpages.ubuntu.com/manpages/jammy/man1/gpasswd.1.html
- ↑ https://www.ibm.com/docs/en/ibm-mq/9.3?topic=windows-creating-managing-groups-linux
- ↑ https://manpages.ubuntu.com/manpages/trusty/man8/groupadd.8.html
- ↑ https://www.ibm.com/docs/en/psfa/7.2.1?topic=groups-delete-linux
- ↑ https://man.archlinux.org/man/vipw.8.en










