Create a Shared Group
Create a Shared Group
Several school assistants need access to the same report folder. Instead of treating each person as the owner of every file, you can define a group that represents the shared role. A Linux group has a name and a numeric group ID, and accounts can have group memberships.
Let's create the school-reports group. This prepares a useful identity for later access rules, but it does not enroll anyone or change a file automatically. We will keep those later steps explicit so shared access is understandable.
What you’ll learn
- Create a group record and inspect it.
- Distinguish group creation from assigning files or enrolling users.
Group creation is only one part of shared access
Create record
groupadd adds a named group with a numeric group ID.
school-reports → GIDEnroll accounts
Membership is assigned separately.
assistant joins groupAssign files
File group ownership is another separate action.
report group = school-reports
Create and inspect school-reports
Prepare the example
Use the disposable VM with administrative authorization. Check whether school-reports already exists before running groupadd. The chosen name represents a role, not a directory that this command will create.
Bash · Linux terminal
sudo groupadd school-reports
getent group school-reportsExpected behavior; machine-dependent details
A group record; assigned GID varies.sudo groupadd school-reports creates the group record according to local defaults. getent group school-reports then displays its lookup result, including the numeric group ID. The exact number is chosen or configured on that system; it is not a fixed value to memorize.
At this point, do not assume assistants have gained access to a report. Enroll an account using the appropriate membership operation, assign the intended file or directory group, and choose permission bits that grant the group's required access. A group name is an ingredient in that policy, not a complete access policy by itself.
Create a role before assigning its membership
Groups let several Linux users share access rules without giving identical permissions to everyone on the system. A group has its own name and numeric group ID.
Understand what a Linux user group is
In Linux, a group is a collection of users. Groups help system administrators manage permissions efficiently. For example, instead of setting permissions for each user, you can assign permissions to a group and add users to that group.
Open a terminal before creating the group
Let’s begin by opening your terminal. You can do this with:
Ctrl + Alt + T
Step 2: Check Existing Groups (Optional)
If you want to see the current groups on your system:
cut -d: -f1 /etc/group
root
daemon
bin
sys
...
Step 3: Create a New Group
We’ll use the groupadd command to create a new group. For example, to create a group named devteam:
sudo groupadd devteam
You’ll be prompted for your password if you’re not the root user.
Step 4: Verify the Group Was Created
Let’s check if the group was successfully created:
getent group devteam
devteam:x:1002:
This means the group exists and currently has no users.
Step 5: Add a User to the Group
To add an existing user (like john) to the new group:
sudo usermod -aG devteam john
The -aG flag appends the user to the group without removing them from others.
Step 6: Apply Group Changes
To make group changes take effect, either log the user out and back in, or use:
newgrp devteam
Step 7: Confirm User's Groups
You can confirm the user's group membership with:
groups john
john : john devteam
Create and verify Linux groups
You’ve successfully created a new user group and added a user to it. Group management is key to secure and scalable Linux system administration.
Try it, then check the worked answer
Your task: Does groupadd automatically move every report into that group?
Use the disposable VM with administrative authorization. Check whether school-reports already exists before running groupadd. The chosen name represents a role, not a directory that this command will create.
Bash · complete example for this question
sudo groupadd school-reports
getent group school-reportsExpected behavior; machine-dependent details
A group record; assigned GID varies.Worked answer
No; file group ownership must be set separately.
Creating the group does not move reports or alter their ownership. A file group is separate metadata changed by an ownership operation. Group membership is separate again. Check each part instead of expecting a group name that resembles a folder to connect them automatically.
Check your decision
A group record does not enroll users or change files
Use groups to represent shared roles, then make membership and file-access choices deliberately. Verify the created record before using its name in another command. The useful question is which people need which operations on which files, not simply whether a group exists.
Reaching the recap and completing the quizzes are separate milestones.