User and Group Management in Red Hat Enterprise Linux (RHEL)

User and group management is one of the most important responsibilities of a Red Hat Enterprise Linux (RHEL) system administrator. From creating and managing user accounts to assigning permissions and organizing groups, these skills ensure security, compliance, and smooth collaboration across the system. This section provides an in-depth look at the commands, configuration files, and best practices every administrator should know.

Common Configuration Files for Users and Groups

Local (non-domain) Linux user and group information is stored in a set of essential configuration files. Understanding these files is critical for troubleshooting and managing accounts securely.

FileDescriptionExample Entry
/etc/​passwdStores basic user account details for the local system such as username, UID, GID, home directory, and default shell.jdoe:x:1001:1001:John Doe:/home/jdoe:/bin/bash
​/etc/​shadowContains encrypted passwords and password policies (expiry, last change, etc) for local users. Only root can access file.jdoe:$6$Y…:19477:0:99999:7:::
/etc/​groupStores local group information including group name, GID, and associated local user members.wheel:x:1002:jdoe,mdoe
​/etc/​login.defsDefines system-wide settings for local user creation defaults, password aging, and UID/GID ranges.PASS_MAX_DAYS 99999
/etc/​default/​useraddHolds default settings for new local user accounts (shell, home dir, etc).HOME=/home

Adding, Modifying, and Removing Local Users

Managing local RHEL users involves creating accounts, updating settings, unlocking accounts, and removing users when no longer needed.

  • Adding a new local user utilizing the useradd command. Example output:
    • The following command creates a user account, jdoe, with the next available UID and GID.
# sudo useradd jdoe
  • Setting or resetting a local user’s password using the passwd command. Example output:
sudo passwd jdoe
  • Modifying an existing local user using the chmod command to change their home directory. Example output:
sudo usermod -s /bin/zsh jdoe
  • Removing an existing local user using the userdel command. Example output:
sudo userdel jdoe
  • Unlocking a user account using the faillock command after too many invalid login attempts. Example output:
sudo faillock --reset --user jdoe

Adding, Modifying, and Removing Local Groups

Groups simplify permissions by assigning access to multiple users at once.

  • Adding a new group with the groupadd command. Example output:
sudo groupadd developers
  • Modifying a group name with the groupmod command. Example output:
sudo groupmod -n devs developers
  • Adding a user to a group with the usermod command. Example output:
sudo usermod -aG devs jdoe
  • Removing a user from a group with the gpasswd command. Example output:
sudo gpasswd -d jdoe devs
  • Deleting a group with the groupdel command. Example output:
sudo groupdel devs

Verifying UID and GID of Users and Groups

To troubleshoot or confirm permissions, it’s important to know the UID (User ID) and GID (Group ID) assigned.

  • Using the id command to show the user’s UID, primary GID, and group memberships. Example output:
#id jdoe
uid=1001(jdoe) gid=1001(jdoe) groups=1001(jdoe),10(wheel)
  • Using the pinky command to display the login name, real name, idle time, and login details. Example output:
#pinky jdoe
Login    Name      TTY     IDLE    WHEN     WHERE:
jdoe     John Doe  pts/0           Aug19    :0

Practice Exercises: User and Group Management in RHEL

Try the following tasks on your RHEL system to reinforce what you’ve learned. Make sure you use sudo where necessary and review the man pages for additional options.

  1. Create a New User
    • Add a new user named “Kane Smith” with username smithk, UID of 1105, a home directory, and a Bash shell.
    • Set a password for the Test User.
  2. Create a New Group and Add Kane Smith
    • Create a group called “testgroup”.
    • Add smithk to the group.
    • Verify group membership by using the id command.
  3. Modify User Settings
    • Change Kane Smith’s shell to /bin/csh
    • Confirm change by checking ​/etc/​passwd
  4. Remove User and Group
    • Remove Kane Smith’s user account but keep the home profile.
    • Remove the testgroup group.

Prev Next