Timedora

Linux User and Group Administration

A practical guide to Linux account identity, account management, and safe administrative access.

Identity, groups, and account records

Numeric identity and group membership

Linux associates users and groups with numeric identifiers: a user ID () and a group ID (). File ownership and access checks use these IDs; account names make the identities easier for people to recognize. A name is therefore not a substitute for the underlying numeric identity used by the system.

Each user has one primary group and may also belong to supplementary groups. Both kinds of group membership are part of how the user is identified in relation to files and access checks. For example, when you inspect an account, distinguish its primary from any additional groups rather than treating all group membership as one undifferentiated list.

Inspect identities and account records

Use id to display a user's , primary , and supplementary groups. For example:

id alex

To query account records, use getent:

getent passwd alex
getent group project

getent looks up information through the configured account databases. With the , those sources may include local files as well as configured network services; which sources are available depends on system configuration. A lookup is therefore not necessarily limited to accounts stored locally.

The local /etc/passwd file contains account metadata such as the username, , primary , home directory, and login shell. Password hashes are normally stored separately in the restricted /etc/shadow file. For routine account administration, use account-management tools rather than editing these files directly.

Creating, changing, and retiring accounts

Create a local account

On systems that provide useradd, create an account and request a home directory with:

sudo useradd -m alex

The -m option requests creation of a home directory. Then set the password interactively:

sudo passwd alex

Entering the password interactively avoids putting it directly in a command line, where it may be exposed in process listings or shell history. Account utilities and their defaults vary by distribution. Debian- and Ubuntu-based systems commonly provide the interactive adduser command instead, so follow the tools and conventions available on the system you are administering.

Add a safely

To create a group and add alex as a supplementary member, use:

sudo groupadd project
sudo usermod -aG project alex

The -a is important when combined with -G: it appends the new group membership. Without -a, usermod replaces the user's existing supplementary-group list, which can unintentionally remove other memberships.

Group changes generally take effect at the user's next login. After that, check the account with either:

id alex
groups alex

These checks help confirm the configured group membership; if it has just been changed, remember that the current login session may not yet reflect it.

Retire an account cautiously

Before deleting an account, consider what depends on it: files, running processes, scheduled jobs, and service access. Account deletion does not necessarily delete the account's files. Archive or remove those files according to the applicable retention requirements. Take particular care with options that recursively remove a home directory, since they can delete data as part of account removal.

Using administrative privileges safely

Run specific authorized commands

Use to run a specific command with elevated privileges when authorized, rather than staying in a root shell for routine work. For example:

sudo apt update

The command you are allowed to run depends on the system's policy. Ubuntu commonly grants administrative access through membership in the group, while other distributions may use a different group or policy. Check your own permitted commands with:

sudo -l

Administrative access should be granted only to trusted accounts. When editing sudoers configuration, use visudo; it checks the configuration for syntax errors while it is being edited.