Linux Users and Groups Explained for Beginners (Complete Guide)
Introduction
If you've ever used a Linux machine, especially if you're in system administration or programming, chances are you've encountered the concepts of Linux users and groups. Some people grasp these concepts immediately, while for others all this information can seem daunting. Don't worryβin this article we'll answer questions like "What are Linux users and groups?", "How does Linux user management work?", and much more.
Why do they exist?
Before we answer the "what" question, I always like to answer "why" first because it makes the bigger picture much clearer. Like many operating systems, Linux is a multi-user operating system, meaning multiple users can use the same machine. This creates problems, especially on the security side of things.
Fortunately, Linux handles this really well. By giving each user their own permissions and isolated workspace, it almost completely (except for self-induced mistakes) eliminates the security issues that come with having multiple users on the same system.
This also becomes very useful on servers, where every user has their own space and only the privileges assigned to them by the administrator, also known as the root user.
What Is a Linux User?
You can think of a Linux user as an entity that has its own privileges and a space where it can apply those privileges.
Every user has:
- A username (e.g.
john,alex) - A UID (User ID), which is unique for every user
- A home directory where permissions are generally configured so the user has full control over it
- A login shell, which starts after every successful login
Depending on your Linux distribution and configuration, the login shell might be Bash, Zsh, Fish, or another shell.
If you want to quickly check your login shell, simply print the $SHELL environment variable (click here to learn more about environment variables).
echo $SHELL
If you want to know which user you're currently logged in as, the whoami command is the right tool.
whoami
Example output:
john
If you want to get information about your current user, use the Linux id command.
id
Example output:
uid=1000(john) gid=1000(john) groups=1000(john),998(wheel)
uid is the User ID, gid is the primary Group ID, and groups lists all the groups this user belongs to.
You might also notice the wheel group. That's outside the scope of this article, but you can read more about the sudo command and the wheel group here.
The Root User
The root user is the administrator of the machine. It has the highest privileges in the system. Like every user, it also has a UID, which is always 0.
It's sometimes referred to as the superuser, so don't get confused if you see that term.
Now you might be thinking: "Why not just use the root user all the time?" There are a couple of reasons why you shouldn't.
While using root, any human error becomes much more costly because you have permission to do almost anything. Also, if you accidentally run malicious software, you're giving it your current privileges, making its job much easier.
So what should you do instead?
Simply use the sudo command (Super User DO). Type sudo before the command you want to run. It will ask for your password, allowing you to use root privileges only when necessary and making you more aware of potentially dangerous actions.
Example:
sudo pacman -Ss ffmpeg
This command runs with root privileges.
System Users
There's one more special type of user: the system user.
Many services use these users to run in a lower-privileged environment. These system users only have access to the files required for the service to function. They also cannot normally log in because they don't have a password or an interactive login shell.
Some examples include:
www-datamysqlnobody
What Is a Linux Group?
A Linux group is simply a collection of multiple users. The main advantage is making permission management much easier.
For example, you can create a group for designers and give that group all the required permissions instead of configuring every user individually. It's faster, cleaner, and greatly reduces human error.
To see all the groups associated with your current user:
groups
To see the groups associated with one or more users:
groups username1 username2 ...
Primary vs Secondary Groups
Just like users, Linux groups have two types.
Every user has one primary group and can belong to as many secondary groups as needed.
The primary group is automatically created when the user is created. It usually has the same name as the username, which often confuses beginners.
By default, every file you create is owned by your primary group unless you change it later (click here to read about Linux permissions).
To add a user to one or more secondary groups:
usermod -aG group1,group2... username
To remove a user from one or more groups:
usermod -rG group1,group2... username
Home Directories
For every user you create, the system automatically creates a home directory (unless you pass the --no-create-home flag).
You can think of it as the user's personal home. It's where they have the most privileges and where most files are owned by them. This is where users usually store their personal files such as Documents, Pictures, Downloads, and more.
It's also where user-specific configuration is stored. Most configuration files are located inside the hidden .config directory.
In Linux, files and directories beginning with a dot (.) are hidden by default.
Change the Password of a User
To change the password of the current user:
passwd
Creating Users
You can use the Linux adduser command to create a new user.
sudo adduser john
How to See Who Is Logged Into a Linux Machine
Use the Linux who command to see who is currently logged in and from which TTY or terminal (click here to learn more about TTYs).
who
Example output:
john tty1 2026-07-14 00:38
Creating Groups
You can use the Linux groupadd command to create a new group.
sudo groupadd developers
Common Beginner Mistakes
Here are a couple of common beginner mistakes in Linux user and group management.
The first is using the root user all the time, like I mentioned earlier. While it might seem convenient, it also increases the chances of accidentally damaging your system or giving malicious software unrestricted access.
Another common mistake is deleting a user but forgetting to remove their home directory and personal files, leaving unnecessary files behind on the system.
Finally, many beginners confuse users with groups. Remember that a user is an individual account, while a group is simply a collection of users used to manage permissions more efficiently.
Related Articles
- Linux File Permissions Explained
- chmod Explained
- Sudo and Wheel Group Explained
- chown vs chgrp
- Linux File System Explained
- What Is TTY?
Conclusion
Linux users and groups are one of the core concepts every Linux user should understand. Once you know how users, groups, and permissions work together, managing Linux systems becomes much easier and much safer.
Hopefully this guide helped clear up the confusion. In the next articles we'll continue building on these fundamentals by exploring chmod, chown, and many other essential Linux commands.
π Enjoyed the article?
Check out my Linux-inspired apparel and programmer-themed designs here:
Top comments (0)