010-160 Users and Group Management 5 — Questions and Answers
Question 1: Which command creates a new group called 'devops' on a Linux system?
- addgroup devops
- groupadd devops (Correct answer)
- newgroup devops
- mkgroup devops
Correct answer: groupadd devops
groupadd devops is the standard command to create a new group entry in /etc/group.
Question 2: What does the 'last' command display?
- The last file modified in the current directory
- A history of user login and logout events (Correct answer)
- The last 10 commands run by the current user
- The last user to modify /etc/passwd
Correct answer: A history of user login and logout events
The last command reads /var/log/wtmp and displays a list of all recent logins, logouts, and system reboots.
Question 3: A system administrator wants to rename the group 'oldteam' to 'newteam'. Which command achieves this?
- groupmod -n newteam oldteam (Correct answer)
- grouprename oldteam newteam
- groupmod -r newteam oldteam
- usermod -G newteam oldteam
Correct answer: groupmod -n newteam oldteam
groupmod -n sets a new name for an existing group, leaving the GID and members intact.
Question 4: What is the minimum number of fields in a valid /etc/passwd entry?
- 5
- 6
- 7 (Correct answer)
- 8
Correct answer: 7
/etc/passwd has exactly 7 colon-separated fields: username, password, UID, GID, GECOS, home directory, and shell.
Question 5: Which command shows only the usernames of users currently logged into the system?
- users (Correct answer)
- who -u
- last -1
- loggedin
Correct answer: users
The users command prints a simple space-separated list of usernames of all currently logged-in users.
Question 6: When using useradd without the -m flag on some distributions, what may NOT be created automatically?
- The user entry in /etc/passwd
- The user's home directory (Correct answer)
- The user's primary group
- The user's shadow password entry
Correct answer: The user's home directory
On some Linux distributions, useradd requires the -m flag to create the home directory; without it, no home directory is created.
Question 7: Which command would allow you to switch to user 'carol' and load her full environment?
- su carol
- su - carol (Correct answer)
- sudo carol
- login carol
Correct answer: su - carol
su - carol (with the hyphen/dash) starts a login shell for carol, loading her environment variables, PATH, and profile scripts.
Which command creates a new group called 'devops' on a Linux system?