010-160 Users and Group Management 4 — Questions and Answers
Question 1: What does the 'w' command show when run on a Linux system?
- Who is logged in and what they are doing (Correct answer)
- The write permissions of the current directory
- Pending writes to disk
- A list of all user accounts
Correct answer: Who is logged in and what they are doing
The w command displays currently logged-in users, their terminals, login times, and the commands they are running.
Question 2: A user's entry in /etc/shadow shows '!' before the password hash. What does this mean?
- The account has no password
- The account is locked (Correct answer)
- The password has expired
- The account requires a password change at next login
Correct answer: The account is locked
A '!' prefix on the password hash in /etc/shadow indicates the account is locked and cannot be used for password authentication.
Question 3: Which command would you use to see the password aging information for a user?
- usermod -l username
- passwd -S username
- chage -l username (Correct answer)
- id --age username
Correct answer: chage -l username
chage -l displays the password aging details including last change date, expiry date, and inactivity period.
Question 4: What is the effect of setting a user's shell to /sbin/nologin?
- The user can only log in via SSH
- The user cannot log in interactively (Correct answer)
- The user is restricted to a chroot environment
- The user's account is deleted at next login
Correct answer: The user cannot log in interactively
/sbin/nologin prints a message and rejects interactive login attempts, commonly used for service accounts.
Question 5: Which file format stores group name, GID, and member list on a Linux system?
- /etc/shadow
- /etc/gshadow
- /etc/group (Correct answer)
- /etc/groupdb
Correct answer: /etc/group
/etc/group stores each group's name, password placeholder, GID, and comma-separated list of member usernames.
Question 6: What happens when you run 'newgrp developers' in a terminal?
- Creates a new group called developers
- Adds the current user to the developers group permanently
- Starts a new shell with developers as the active primary group (Correct answer)
- Lists all members of the developers group
Correct answer: Starts a new shell with developers as the active primary group
newgrp spawns a new shell session where the specified group becomes the user's active primary group for that session.
Question 7: Which useradd option specifies a comment (typically the user's full name) for the account?
- -n
- -c (Correct answer)
- -d
- -m
Correct answer: -c
The -c option sets the GECOS comment field in /etc/passwd, which traditionally stores the user's full name.
What does the 'w' command show when run on a Linux system?