Red Hat Enterprise Linux Administration
Lecture #04
Users and Groups in Linux
Types of Users
1. Local Users (Exist on a single machine)
○ Root (Super User):
■ Can do anything, including modifying system files.
○ System Users:
■ These users cannot log in but are needed for services to run.
■ Examples: http, mysql.
○ Normal Users:
■ Limited permissions unless modified.
■ Example: A normal user like kashif.
2. Global Users (Used in network environments)
○ Managed in networked environments like Active Directory (AD).
○ Used for centralized user management across multiple machines.
User ID (UID) and Group ID (GID)
● UID (User ID):
○ 0 → Root.
○ 1-999 → System users.
○ 1000-60000 → Normal users.
● GID (Group ID):
○ 0 → Root group.
○ 1-999 → System groups.
○ 1000-60000 → Normal user groups.
Its default id’s we can change it
User-Related Directories
Directory Purpose
/root Home directory of the root user.
/home Contains home directories for normal users.
/etc/passwd Stores user account information.
/etc/shadow Stores encrypted user passwords.
/etc/login.defs Defines default settings for user creation.
etc/passwd file and contains user account information in Linux. Each field has a specific
meaning.
Field Value Meaning
Username shadow01 The login name of the user.
Password x The actual password is stored in /etc/shadow (not
Placeholder visible here).
User ID (UID) 1000 The unique ID assigned to this user (1000+ means a
normal user).
Group ID (GID) 1000 The primary group ID of the user.
User Description Shadow 01 A comment or description (set during user creation
(Comment) with -c).
Home Directory /home/shado The user's personal folder.
w01
Login Shell /bin/bash The default shell for this user (e.g., Bash, Zsh).
Tab Button for Auto-Completion
● When typing a command, Just write the first one or two letters and press Tab to
auto-complete a command, filename, or directory name.
● Works for short words and common Linux commands.
User Management Commands
Creating a User
Basic user creation:
useradd Ali
○ Creates a user but does not set a password.
Setting a password:
passwd Ali
○ Prompts to enter a password (you won’t see it as you type).
Password must be show when we type:
password Ali - -stdin
Leave a user without a password:
password -d Ali
○ Not Recommended.
Modifying Users
Check user details:
id kashif
○ Shows UID of user kashif.
Creating a user with a specific UID:
useradd -u 1050 kashif
○ Assigns UID 1050 to kashif instead of a default one.
Change user details:
usermod -c "IT Team" kashif
○ -c (comment) adds a description to the user.
Change login name:
usermod -l Kashi kashif
○ Renames the user from kashif to Kashi.
Deleting Users
Delete a user (but keep home directory):
userdel Adil
○ Removes the user but keeps their files.
Delete a user and their home directory:
userdel -r Ali
○ -r deletes the user and their home directory.
Force delete a user and their profile directory:
userdel -rf Ali
○ -rf removes the user forcefully (including any files and processes).
Switching Users
Basic switch:
su Asif
○ Switches to the user Asif (but keeps the current environment).
Switch and load full user environment:
su - Asif
○ Loads Asif’s full profile and environment (/home/Asif).
Prepared by: Tasneem Ulhaq