Download Article
A complete guide to managing user groups in Linux
Download Article
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
Ask a Question
200 characters left
Include your email address to get a message when this question is answered.
Submit
Advertisement
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] X Research sourceThanks
- 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
Submit a Tip
All tip submissions are carefully reviewed before being published
Name
Please provide your name and last initial
Thanks for submitting a tip for review!
Advertisement
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
About This Article
Thanks to all authors for creating a page that has been read 4,282 times.
Advertisement