Unit 7 subjective questions User and Group Administration
CSE105 — Creative Engineering Workshop 20 questions with model answers. Write yours first, then compare.
-
Question 1 of 20
Define a user account in Linux. Explain the difference between a system account and a normal user account.
Model answer
A user account in Linux is an identity that allows a person or process to log in and interact with the system. Each account is associated with a unique User ID (UID) and has attributes like a home directory, login shell, and group membership.
System Accounts:
- Used by services and daemons rather than humans (e.g.,
daemon,bin,mail). - Typically have UIDs in the range 0–999 (0 is reserved for
root). - Often have
/usr/sbin/nologinor/bin/falseas their shell to prevent interactive login.
Normal User Accounts:
- Created for actual human users.
- UIDs usually start from 1000 and above.
- Have a valid login shell (e.g.,
/bin/bash) and a home directory under/home.
The key distinction lies in purpose (service vs human), UID range, and whether interactive login is permitted.
- Used by services and daemons rather than humans (e.g.,
-
Question 2 of 20
Explain the purpose and syntax of the
useraddcommand. Describe at least four commonly used options with examples.Model answer
The
useraddcommand is used to create a new user account or update default new-user information in Linux.Basic Syntax:
bash
useradd [options] usernameCommonly Used Options:
-
-m: Creates the user's home directory.
bash
useradd -m john -
-d: Specifies a custom home directory.
bash
useradd -d /data/john john -
-s: Sets the login shell.
bash
useradd -s /bin/bash john -
-g: Sets the primary group.
bash
useradd -g developers john -
-G: Adds the user to supplementary groups.
bash
useradd -G sudo,docker john -
-u: Assigns a specific UID.
bash
useradd -u 1500 john
After creation, a password must usually be set with
passwd usernamebefore the account can be used. -
-
Question 3 of 20
Describe the
usermodcommand in detail. How can it be used to modify user attributes such as group membership, home directory, and shell?Model answer
The
usermodcommand modifies an existing user account's properties.Basic Syntax:
bash
usermod [options] usernameKey Options:
-
-l newname: Changes the login name.
bash
usermod -l johnny john -
-d newdir: Changes the home directory (use-mto move contents).
bash
usermod -d /home/johnny -m johnny -
-s shell: Changes the login shell.
bash
usermod -s /bin/zsh johnny -
-g group: Changes the primary group.
bash
usermod -g staff johnny -
-aG groups: Appends the user to supplementary groups (the-aflag prevents removal from other groups).
bash
usermod -aG sudo,docker johnny -
-L/-U: Lock / unlock the account.
Important: Omitting
-awith-Gwill replace all existing supplementary groups, which is a common mistake. -
-
Question 4 of 20
Explain the
userdelcommand. What is the significance of the-roption, and what precautions should be taken while deleting a user?Model answer
The
userdelcommand removes a user account from the system.Basic Syntax:
bash
userdel [options] usernameThe
-rOption:-
Removes the user's home directory and mail spool along with the account.
bash
userdel -r john -
Without
-r, only the account entry is removed while files remain on disk.
The
-fOption:- Forces removal even if the user is currently logged in (use with caution).
Precautions:
- Back up important data before deletion, as
-ris irreversible. - Ensure the user is not logged in or running critical processes.
- Check for files owned by the user elsewhere in the filesystem (e.g., using
find / -user john) to avoid orphaned files. - Reassign ownership of any shared files the user owned.
-
-
Question 5 of 20
Describe the structure of the
/etc/passwdfile. Explain each of its seven fields with an example entry.Model answer
The
/etc/passwdfile stores essential information about each user account. Each line represents one user, with seven colon-separated fields.Example Entry:
john:x:1001:1001:John Doe:/home/john:/bin/bash
Field Breakdown:
- Username (
john) : Login name of the user. - Password (
x) : Placeholder; the actual encrypted password is stored in/etc/shadow. - UID (
1001) : Numeric User ID. - GID (
1001) : Primary Group ID. - GECOS (
John Doe) : Comment field, usually the full name or contact info. - Home Directory (
/home/john) : User's home directory. - Login Shell (
/bin/bash) : The shell executed on login.
The file is world-readable but only editable by
root, which is why passwords are stored separately in the protected/etc/shadowfile. - Username (
-
-
Question 6 of 20
Explain the structure of the
/etc/groupfile. How does it define group memberships in Linux?Model answer
The
/etc/groupfile defines the groups on a Linux system. Each line represents one group and contains four colon-separated fields.Example Entry:
developers:x:1005:john,mary,alex
Field Breakdown:
- Group Name (
developers) : The name of the group. - Password (
x) : Group password placeholder; actual value (if any) is in/etc/gshadow. - GID (
1005) : Numeric Group ID. - Member List (
john,mary,alex) : Comma-separated list of usernames who are supplementary members of the group.
Key Points:
- A user's primary group is defined in
/etc/passwd, not necessarily listed here. - The member field lists only secondary/supplementary memberships.
- The file is world-readable and managed via commands like
groupadd,groupmod, andusermod.
- Group Name (
-
Question 7 of 20
Distinguish between a primary group and a secondary (supplementary) group. Explain how each is assigned to a user.
Model answer
Primary Group:
- Every user has exactly one primary group.
- Defined by the GID field in
/etc/passwd. - Files created by the user are owned by this group by default.
- Assigned during account creation (e.g.,
useradd -g developers john).
Secondary (Supplementary) Group:
- A user can belong to multiple secondary groups.
- Membership is recorded in the member list of
/etc/group. - Grants additional access permissions beyond the primary group.
- Assigned using
useradd -Gor appended later withusermod -aG.
Comparison Table:
Feature Primary Group Secondary Group Count per user Exactly one Zero or more Defined in /etc/passwd/etc/groupDefault file ownership Yes No Command usermod -gusermod -aGUse the
id usernamecommand to view both primary and secondary group memberships. -
Question 8 of 20
Explain the
groupadd,groupmod, andgroupdelcommands with syntax and examples for each.Model answer
These three commands manage groups in Linux.
1.
groupadd— Create a new group:
bash
groupadd [options] groupname
groupadd developers # create group
groupadd -g 1500 developers # create with specific GID2.
groupmod— Modify an existing group:
bash
groupmod [options] groupname
groupmod -n devteam developers # rename group
groupmod -g 1600 devteam # change GID3.
groupdel— Delete a group:
bash
groupdel groupname
groupdel devteamImportant Notes:
- A group cannot be deleted if it is the primary group of any existing user.
- Changing a GID with
groupmod -gdoes not automatically update file ownership for files owned by the old GID. - These operations require root privileges.
-
Question 9 of 20
Describe the
passwdcommand and explain how password management works in Linux. Include options for locking, expiring, and forcing password changes.Model answer
The
passwdcommand manages user passwords in Linux.Basic Usage:
bash
passwd # change your own password
passwd john # root changes john's passwordUseful Options:
-
-l: Lock a user's password (disables login via password).
bash
passwd -l john -
-u: Unlock a locked password.
bash
passwd -u john -
-e: Expire the password immediately, forcing a change at next login.
bash
passwd -e john -
-d: Delete the password (makes it passwordless — risky). -
-S: Show password status information.
How It Works:
- Passwords are hashed (using algorithms like SHA-512) and stored in
/etc/shadow, not/etc/passwd. - Related aging policies (min/max days, warnings) can be tuned using the
chagecommand. - Only
rootcan change another user's password.
-
-
Question 10 of 20
Explain the
/etc/shadowfile and its importance. Describe its major fields and how it enhances security compared to/etc/passwd.Model answer
The
/etc/shadowfile stores encrypted password hashes and password aging information for user accounts. It is readable only by root, unlike the world-readable/etc/passwd.Example Entry:
john:abc123$xyz...:19500:0:99999:7:::
Major Fields:
- Username : Login name.
- Encrypted Password : Hashed password (
$6$indicates SHA-512). - Last Change : Days since Jan 1, 1970 when password was last changed.
- Minimum Age : Minimum days before password can be changed.
- Maximum Age : Maximum days the password is valid.
- Warning Period : Days before expiry to warn the user.
- Inactivity Period : Days after expiry before the account is disabled.
- Expiration Date : Account expiry date.
Security Advantage:
- Moving hashes out of the world-readable
/etc/passwdprevents ordinary users from performing offline password-cracking attacks on the hashes.
-
Question 11 of 20
Compare the
useraddandaddusercommands. Why might an administrator prefer one over the other?Model answer
Although similar in purpose,
useraddandadduserdiffer significantly.useradd:- A low-level binary utility available on virtually all Linux distributions.
- Non-interactive by default; requires explicit options (
-m,-s, etc.). - Does not automatically create a home directory unless
-mis specified (behavior may depend on defaults).
adduser:- A high-level Perl script (mainly on Debian/Ubuntu systems).
- Interactive — prompts for password, full name, and other details.
- Automatically creates the home directory, copies skeleton files from
/etc/skel, and sets sensible defaults.
Comparison Table:
Feature useradd adduser Type Binary Script Interactivity No Yes Portability Universal Debian-based Ease of use Lower Higher Preference: Administrators favor
adduserfor quick interactive setup on Debian systems, whileuseraddis preferred for scripting and automation across all distributions. -
Question 12 of 20
A user's supplementary groups were accidentally overwritten. Explain what likely caused this and demonstrate the correct way to add a user to multiple groups without losing existing memberships.
Model answer
Likely Cause:
The administrator usedusermod -Gwithout the-a(append) flag. The-Goption replaces the entire list of supplementary groups, so any groups not listed in the command are silently removed.Incorrect (destructive) command:
bash
usermod -G docker johnThis makes
dockerthe only supplementary group, removingjohnfrom all others.Correct Approach — use
-aG:
bash
usermod -aG docker,sudo johnThe
-aflag appends the specified groups to the existing set, preserving prior memberships.Verification:
bash
id john # lists all current groups
groups john # alternative checkRecovery Tip: If groups were lost, re-add them explicitly:
bash
usermod -aG groupA,groupB,groupC johnBest Practice: Always include
-awhen using-Gunless you deliberately intend to reset all supplementary memberships. -
Question 13 of 20
Explain the significance of UID 0 in Linux. What are the security implications of a non-root account having UID 0?
Model answer
UID 0 is reserved for the
rootsuperuser in Linux. The kernel grants unrestricted privileges to any account whose UID is 0, regardless of the account's name.Significance:
- Root can read, write, and delete any file, kill any process, and modify system configuration.
- Access control checks are effectively bypassed for UID 0.
Security Implications of Duplicate UID 0:
- If a normal account is assigned UID 0 (e.g.,
useradd -o -u 0 hacker), it gains full root privileges while appearing to be an ordinary user. - This is a classic backdoor technique used by attackers to hide privileged access.
- Such accounts can escalate privileges without using the
rootlogin, making detection harder.
Best Practices:
-
Regularly audit
/etc/passwdfor multiple UID 0 entries:
bash
awk -F: '1}' /etc/passwd -
Ensure only
rootlegitimately holds UID 0. -
Use
sudofor delegated privileges instead of shared root accounts.
-
Question 14 of 20
Describe the role of the
/etc/skeldirectory in user account creation. How does it relate to theuseraddcommand?Model answer
The
/etc/skel(skeleton) directory contains template files and directories that are automatically copied into a new user's home directory when the account is created.How It Works:
- When
useradd -m(oradduser) creates a home directory, the contents of/etc/skelare copied into it. - Typical files include
.bashrc,.bash_profile,.profile, and default configuration folders.
Example:
bash
useradd -m -k /etc/skel johnThe
-koption explicitly specifies the skeleton directory to use.Purpose / Benefits:
- Provides a consistent environment for all new users.
- Allows administrators to preconfigure shell settings, aliases, and welcome files organization-wide.
Customization:
- Adding a file to
/etc/skel(e.g., a company usage policy) ensures every future user receives it automatically. Existing users are not affected retroactively.
- When
-
Question 15 of 20
Explain the
chagecommand and its role in password aging. Describe at least four options with examples.Model answer
The
chage(change age) command manages password aging and account expiration policies for users. The information it controls is stored in/etc/shadow.Basic Syntax:
bash
chage [options] usernameKey Options:
-
-l: List current aging information.
bash
chage -l john -
-M days: Set maximum number of days a password is valid.
bash
chage -M 90 john -
-m days: Set minimum number of days between password changes.
bash
chage -m 7 john -
-W days: Set the warning period before expiry.
bash
chage -W 5 john -
-E date: Set an account expiration date.
bash
chage -E 2026-12-31 john -
-d 0: Force password change at next login.
Use Case:
chageenforces security compliance by ensuring passwords are rotated periodically and accounts expire when access is no longer needed. -
-
Question 16 of 20
Illustrate the complete lifecycle of a user account in Linux — from creation to deletion — including relevant commands and the files affected at each stage.
Model answer
The user account lifecycle involves several stages, each touching specific system files.
1. Creation:
bash
useradd -m -s /bin/bash john- Files affected:
/etc/passwd,/etc/shadow,/etc/group, and the home directory (/home/john) populated from/etc/skel.
2. Setting a Password:
bash
passwd john- File affected:
/etc/shadow(stores the hash).
3. Modification (e.g., add to groups, change shell):
bash
usermod -aG sudo john
usermod -s /bin/zsh john- Files affected:
/etc/group,/etc/passwd.
4. Password Aging / Policy Enforcement:
bash
chage -M 90 john- File affected:
/etc/shadow.
5. Locking (temporary disable):
bash
usermod -L john # or passwd -l john6. Deletion:
bash
userdel -r john- Files affected: entries removed from
/etc/passwd,/etc/shadow,/etc/group; home directory and mail spool deleted.
Summary: Throughout the lifecycle, the four core files —
/etc/passwd,/etc/shadow,/etc/group, and/etc/gshadow— are continuously updated to reflect the account's state. - Files affected:
-
Question 17 of 20
Distinguish between the
/etc/passwd,/etc/shadow,/etc/group, and/etc/gshadowfiles by tabulating their purpose, content, and permissions.Model answer
These four files together form the core of Linux user and group administration.
File Purpose Key Contents Typical Permissions /etc/passwdStores user account info username, UID, GID, home dir, shell -rw-r--r--(644)/etc/shadowStores encrypted passwords & aging password hash, aging fields -rw-------(600/640)/etc/groupDefines groups group name, GID, members -rw-r--r--(644)/etc/gshadowSecure group data group password, admins, members -rw-------(600)Key Observations:
passwdandgroupare world-readable because many programs need to map UIDs/GIDs to names.shadowandgshadoware restricted to root because they contain sensitive password hashes.- The separation of readable metadata from sensitive hashes is a fundamental security design in Linux.
Consistency Check: Tools like
pwckandgrpckverify the integrity of these files. -
Question 18 of 20
Explain the concept of account locking in Linux. Compare the different methods (
usermod -L,passwd -l, setting shell to/sbin/nologin) and their effects.Model answer
Account Locking temporarily prevents a user from logging in without deleting the account.
Methods:
1.
passwd -l username:- Prepends a
!to the password hash in/etc/shadow, making the hash invalid. - Prevents password-based login.
- Does not block SSH key-based login or other authentication methods.
2.
usermod -L username:- Functionally similar to
passwd -l; locks the password field. - Use
usermod -Uto unlock.
3. Setting shell to
/sbin/nologinor/bin/false:
bash
usermod -s /sbin/nologin john- Prevents an interactive shell, so even if authentication succeeds, no shell session starts.
/sbin/nologinpolitely displays a message;/bin/falseexits silently.
Comparison Table:
Method Blocks Password Login Blocks SSH Keys Blocks Shell passwd -lYes No No usermod -LYes No No nologinshellNo No (but no shell) Yes Best Practice: For a complete lockout, combine password locking with a
nologinshell. - Prepends a
-
Question 19 of 20
Describe how default values for new users are configured in Linux. Explain the role of the
/etc/login.defsand/etc/default/useraddfiles.Model answer
When creating users, Linux relies on default configuration files to fill in unspecified attributes.
1.
/etc/default/useradd:- Contains default settings used by the
useraddcommand, such as:GROUP: Default primary group.HOME: Base directory for home folders (e.g.,/home).SHELL: Default login shell.SKEL: Skeleton directory (/etc/skel).INACTIVEandEXPIRE: Default aging settings.
- View/modify defaults:
bash
useradd -D # display defaults
useradd -D -s /bin/bash # change default shell
2.
/etc/login.defs:- Defines system-wide policy for user and password management, including:
UID_MIN/UID_MAX: Range for normal user UIDs.GID_MIN/GID_MAX: Range for group GIDs.PASS_MAX_DAYS,PASS_MIN_DAYS,PASS_WARN_AGE: Default password aging.CREATE_HOME: Whether to create home directories automatically.
Together, these files ensure consistent and policy-compliant account creation across the system.
- Contains default settings used by the
-
Question 20 of 20
A company requires a shared project directory accessible by a team. Explain step-by-step how you would create a group, add users, and configure the directory with appropriate group ownership and permissions (including the SGID bit).
Model answer
Objective: Set up a collaborative directory
/projectfor a team of users.Step 1 — Create the group:
bash
groupadd projectteamStep 2 — Add users to the group:
bash
usermod -aG projectteam alice
usermod -aG projectteam bob
usermod -aG projectteam carolStep 3 — Create the shared directory:
bash
mkdir /projectStep 4 — Set group ownership:
bash
chgrp projectteam /projectStep 5 — Set permissions with the SGID bit:
bash
chmod 2770 /project- The leading
2sets the SGID (Set Group ID) bit. 770grants full access to owner and group, none to others.
Why the SGID Bit Matters:
- With SGID on a directory, all files created inside inherit the directory's group (
projectteam) rather than the creator's primary group. - This ensures every team member can access newly created files.
Step 6 — Verify:
bash
ls -ld /project # should show drwxrws--- projectteam
id alice # confirm group membershipResult: All team members can collaboratively create and edit files, with consistent group ownership maintained automatically.
- The leading
That's unit 7
Long answers stick best when they're tested again soon. Run the MCQs on this unit, then come back to the questions you found hardest.
Nearly through. Did unit 7 of CSE105 save you a night before the exam?
LPU Notes is free. A student pays for the servers.
Did unit 7 of CSE105 save you a night before the exam?
Then you can help keep it free for the next batch. Ads cover part of the server bill; the rest comes out of a student's own pocket: the domain, the storage, and keeping the site up through the weeks everyone needs it at once.
The payment button didn't load. An ad blocker or a filtered network is the usual reason. to try again.
Nothing here is ever locked, and nothing unlocks.