User Management in Linux

Amit JajooAmit Jajoo
2 min read

In Linux there are 3 user type:

  1. Root user → Root user id is 0.

  2. System user → System user has ids from 1 to 999.

  3. Local user → Local user has ids greater than 999.

Why we don’t use root user for everyday task ?

If there are two users, John and Jane, both of whom can use the root account, and one of them uses rm -rf, it would be difficult to determine who is responsible. Therefore, we should create separate accounts with the same sudo privileges so that we can track user activity through logs.

Commands

  1. whoami → username of the system

  2. sudo cat /etc/passwd → List the user in the system

    root:x:0:0:root:/root:/bin/bash

    root→username

    x→ password placeholder

    0→User ID (UID)

    0→Group ID (GID)

    root → User description (GECOS)

    /root → Home directory

    /bin/bash → Login shell (default shell)

  3. sudo cat /etc/shadow → To get the user password

  4. To create users we have two different method

    1. Low level Command

      sudo useradd amit

      sudo passwd amit

      We don’t create users at a low level because we also have to create groups and set other permissions.

    2. High Level Command

      sudo adduser amit

  5. sudo cat /etc/group → To get the group information

  6. To add user in a group:

    sudo usermod -aG groupname username

  7. Remove group

    sudo delgroup groupname

  8. To change the name of user

    sudo usermod -l newname oldname

What is sudo ?

sudo is a group. sudo stands for "superuser do." Most system-level operations (like installing software, modifying system files, or restarting services) require elevated privileges. sudo allows you to perform these operations without logging in as the root user, which is safer.

Key Benefits:

  • Security: Avoids using the root account directly.

  • Auditability: Logs all sudo usage.

  • Control: Admins can fine-tune what commands a user can run via sudo.

0
Subscribe to my newsletter

Read articles from Amit Jajoo directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Amit Jajoo
Amit Jajoo