Home Linux BasicsLinux Users, Groups and sudo Explained for Beginners

Linux Users, Groups and sudo Explained for Beginners

by Knowledge Base Linux
Linux Users Groups and sudo Explained — Linux Users, Groups and sudo Explained for Beginners

Linux was designed from the start for many people sharing one computer, and that heritage shapes everything. Linux users and groups decide who you are on the system, which files are yours, and what you are allowed to touch. This guide explains Linux users and groups in plain English – what accounts and groups are, who the all-powerful root user is, and what that famous word sudo actually does when you type it. This article covers Linux Users Groups and sudo Explained in detail.

Linux Users and Groups: Who Is Who on the System – Linux Users Groups and sudo Explained

A user is an identity with a username, a password, and a home folder. Some users are humans, like you. Others are “system users” created for programs – the web server, for example, runs as its own limited user so that if it is ever attacked, the damage stays contained. Each user also has a number, the UID; the system trusts the number, the name is just for us humans.

A group is exactly what it sounds like: a named bucket of users who share access to something. Instead of granting a permission to ten people one by one, you grant it to their group once. A user has one main group (usually a group with the same name as the user) and can belong to many extra ones. Curious who you are? Two tiny commands answer:

$ whoami
alex
$ id
uid=1000(alex) gid=1000(alex) groups=1000(alex),27(sudo),1001(team)

That output quietly tells a story: Alex is user 1000, belongs to the team group, and to a very interesting group called sudo – keep it in mind for a moment. Permissions on files refer to these owners and groups, which is exactly how the system in our file permissions guide works.

Meet root: The All-Powerful Administrator – Linux Users Groups and sudo Explained

One account stands above all rules: root, the superuser, UID 0. Root can read any file, change any setting, and delete anything – including, accidentally, the system itself. Root also has its own home folder, /root, separate from everyone else’s.

Because root is so powerful, daily work should never be done as root. Modern distributions (Ubuntu famously) even lock root’s password by default. Instead, trusted humans get a safer tool for borrowing that power only when needed – which brings us to the word you have been waiting for.

Linux users and groups - using a golden key with sudo to open a locked door

Why Linux Users and Groups Rely on sudo

sudo stands for “superuser do.” Placed before a command, it runs that one command with root’s powers, after asking for your password (not root’s) to confirm it is really you:

$ sudo apt update      # install system updates with admin rights
$ sudo nano /etc/hosts # edit a system file

Only users listed in a configuration file – traditionally those in the sudo group, like Alex above – may use it. That is why adding someone to the system as an administrator means adding them to that group, as we show step by step in our practical guide to adding a user to sudo on Debian. The password prompt stays cached for a few minutes, so you are not asked for every single command.

Think of sudo as a safety interlock: the power is available, but you must deliberately reach for it each time, which gives you a split second to notice when a command looks wrong. The official sudo project site documents its history and options.

Creating a New User: The 30-Second Version

Seeing Linux users and groups in action is easy: create a practice account. On Ubuntu and Debian, one friendly command asks the setup questions for you:

$ sudo adduser sam
$ sudo usermod -aG team sam   # add Sam to the team group (-a means append!)

The first line creates the user, their home folder, and their password. The second shows how group membership changes: usermod modifies the account, and the -aG flags mean “append to these groups” – leave out the -a and you would replace all of Sam’s extra groups, a classic accident. Sam’s new membership takes effect at their next login. Removing an account later is just as simple with sudo deluser sam. That is the whole lifecycle of Linux users and groups in miniature: create, assign groups, borrow power with sudo, and clean up when someone leaves.

Common Beginner Mistakes with Users and sudo

  • Working as root all day “to save time.” One typo as root can erase the system; as a normal user, the same typo just errors. Sudo exists to keep that protection.
  • Putting sudo in front of everything. If a normal task needs sudo inside your own home folder, the file ownership is probably broken – fix that instead of forcing it.
  • Sharing accounts. Give every person their own user. Shared logins make it impossible to know who changed what, and changing a shared password locks everyone out.
  • Forgetting your own groups until you reboot. New group memberships usually apply at your next login, not instantly in the current session.

Conclusion

Linux users and groups are the system’s identity system: users own things, groups share access, root rules over all of it, and sudo lets trusted people borrow that rule one careful command at a time. Check yourself with whoami and id, and the permission messages from earlier lessons will suddenly make sense. Changing your own password is the natural next chore – see our quick guide to changing a user password on Ubuntu.

You may also like

KbLinux

Typically replies within a day

Hello, Welcome to the site. Please click below button for chatting me through Telegram.