DEV Community

Sreekanth Kuruba
Sreekanth Kuruba

Posted on

Linux User & Group Management Explained Simply

Ever wondered how Linux knows:

who can access what, and what they are allowed to do?

That’s not random.

It’s controlled by users and groups — one of the most important concepts in Linux security and DevOps.

Let’s break it down simply.


What is a User in Linux?

A user is an account that interacts with the Linux system.

Every user has:

  • Username
  • User ID (UID)
  • Home directory
  • Default shell

Everything in Linux runs under a user identity.

Examples:

  • A developer user
  • A system admin user
  • A service user (like nginx)

What is a Group in Linux?

A group is a collection of users.

Think of it like a team:

  • Developers group → devs
  • QA group → testers
  • Admins group → system administrators

👉 Instead of assigning permissions one by one, you assign them to a group.

This makes Linux scalable and manageable.


Check Current User & Groups

whoami
Enter fullscreen mode Exit fullscreen mode

Shows your current logged-in user.

id
Enter fullscreen mode Exit fullscreen mode

Shows:

  • User ID (UID)
  • Group ID (GID)
  • All groups the user belongs to
groups
Enter fullscreen mode Exit fullscreen mode

Shows all groups of the current user.


Creating a User

sudo useradd john
Enter fullscreen mode Exit fullscreen mode

Creates a new user named john.

Note: This may not create a home directory in some systems.

Better way (recommended on Ubuntu/Debian):

sudo adduser john
Enter fullscreen mode Exit fullscreen mode

👉 Automatically creates home directory + setup


Setting Password

sudo passwd john
Enter fullscreen mode Exit fullscreen mode

Used to set or update user password.


Modifying Users (usermod)

sudo usermod -aG developers john
Enter fullscreen mode Exit fullscreen mode

Adds user john to developers group.

Other examples:

sudo usermod -l newname oldname   # rename user
sudo usermod -d /new/home john    # change home directory
Enter fullscreen mode Exit fullscreen mode

Deleting Users

sudo userdel john
Enter fullscreen mode Exit fullscreen mode

Removes user only.

Remove user + home directory:

sudo userdel -r john
Enter fullscreen mode Exit fullscreen mode

Managing Groups

Creating a Group

sudo groupadd developers
Enter fullscreen mode Exit fullscreen mode

Deleting a Group

sudo groupdel developers
Enter fullscreen mode Exit fullscreen mode

Important System Files

/etc/passwd

Stores user information:

username:x:UID:GID:comment:home:shell
Enter fullscreen mode Exit fullscreen mode

Example:

john:x:1001:1001::/home/john:/bin/bash
Enter fullscreen mode Exit fullscreen mode

👉 This file contains all users in the system.


/etc/group

Stores group information:

group_name:x:GID:user_list
Enter fullscreen mode Exit fullscreen mode

Example:

developers:x:1002:john,mike
Enter fullscreen mode Exit fullscreen mode

👉 Shows which users belong to which group.


What is sudo?

sudo allows a user to run commands as an administrator (root).

Example:

sudo apt update
Enter fullscreen mode Exit fullscreen mode

Why sudo is important

Linux protects system files.

Normal users cannot modify system-level settings.

👉 sudo gives temporary admin power.


Important sudo concept

  • Not every user has sudo access
  • Only users in sudo or wheel group can use it

Check your groups:

groups
Enter fullscreen mode Exit fullscreen mode

Real-World Example

In a company server:

  • Developers → normal users
  • Admins → sudo users
  • Services → system users (nginx, docker, etc.)

Each user has restricted access based on role

This keeps systems:

  • security
  • structure
  • control ⚙️

Why User & Group Management Matters

In DevOps and system administration:

You use this to:

  • control server access
  • manage teams on shared systems
  • secure applications
  • isolate services

Without it:

Linux systems become unmanageable and insecure


Summary

In this guide you learned:

  • What users are in Linux
  • What groups are
  • whoami, id, groups
  • useradd, adduser
  • usermod usage
  • userdel and cleanup
  • groupadd, groupdel
  • /etc/passwd structure
  • /etc/group structure
  • sudo basics
  • Real-world DevOps usage

Next Post:

Linux Process Management Explained Simply, (ps, top, htop, kill)


Question for You

Have you ever worked on a shared Linux server where multiple users caused confusion or permission issues?

I’ll show how real systems solve that in Part 5.

Top comments (0)