Local System Administration Creating Local User Groups
Local System Administration Creating Local User Groups
Groups
Overview
Groups are an important way of managing users abilities to access, write, and execute files
on a Linux system. Adding a user to the correct group can enable them to do things like
read web server logs without allowing the user to modify the logs. Appropriately managing
groups for multiple users along with file permissions can enable users to collaboratively
edit files. On systems where su or sudo access are not available, newgrp and sg tools can
be used to run tasks with a different group if elevated privileges are required. Creating and
managing groups is usually only done as root.
Key Ideas
GID: numeric value of a groups ID
groups: command to show a users group memberships
groupadd: tool to add groups to a Linux system
groupmod: tool to modify groups on a Linux system
groupdel: tool to remove groups on a Linux system
/etc/group: File where group information is stored
/etc/gshadow: File where secure group information is stored
Example Scenario
Create a new group in order to collaborate with other users on a system. Create an example
directory with some files in it such that group members can collaboratively edit the files.
Finally, remove the group from the system.
Now Do It
1. Create a group called developers with GID 5000
2. Create a directory called shared-files
3. Make a few empty files inside the shared-files directory
4. Change the group ownership of the directory and files inside it to developers
5. Check that the files and directory have the correct ownership
6. Now rename the group to devs
42
43
Answer Key
1. # groupadd -g 5000 developers
2. # mkdir shared-files
3. # touch shared-files/test1.txt; touch shared-files/test2.txt; touch shared-files/test3.
txt
4. # chgrp -Rv developers shared-files
5. # ls -alh shared-files
6. # groupmod -n devs developers
7. # ls -alh shared-files
8. # chmod g+rwx shared-files; chmod g+rw shared-files/*
9. # groupdel devs
44
Get Certified!
Get more information at http://training.linuxfoundation.org/certification/lfcs