LCA User & Permission Management 3 — Questions and Answers
Question 1: Which command displays the numeric UID and GID of the current user along with all supplementary group memberships?
- whoami
- groups
- id (Correct answer)
- finger
Correct answer: id
The id command shows the current user's UID, primary GID, and all supplementary group IDs.
Question 2: What does the command 'newgrp developers' accomplish?
- Creates a new group named developers
- Adds the current user to the developers group permanently
- Starts a subshell with developers as the effective primary group (Correct answer)
- Renames the current group to developers
Correct answer: Starts a subshell with developers as the effective primary group
newgrp opens a new shell session where the specified group becomes the user's effective primary group for that session.
Question 3: Which useradd option specifies a comment (GECOS field) such as the user's full name?
- -g
- -c (Correct answer)
- -d
- -s
Correct answer: -c
The -c option sets the GECOS/comment field, typically used for the user's full name or description.
Question 4: A file has permissions 664. What is the symbolic equivalent for the 'others' portion?
- rw-
- r-x
- r-- (Correct answer)
- ---
Correct answer: r--
The last octal digit 4 equals binary 100, which maps to read-only (r--).
Question 5: Which file defines default settings (like UMASK and home directory skeleton path) used by useradd?
- /etc/passwd
- /etc/login.defs
- /etc/skel
- /etc/default/useradd (Correct answer)
Correct answer: /etc/default/useradd
/etc/default/useradd stores defaults for the useradd command such as SHELL, HOME, INACTIVE, and EXPIRE.
Question 6: What effect does setting UMASK to 027 have on newly created files?
- Files get permissions 027
- Files get permissions 640 (Correct answer)
- Files get permissions 750
- Files get permissions 777
Correct answer: Files get permissions 640
A umask of 027 subtracts from the default 666 for files: 666 - 027 = 640 (rw-r-----).
Question 7: Which command is used to add an existing user 'alice' to the supplementary group 'sudo' without removing her from other groups?
- usermod -g sudo alice
- usermod -aG sudo alice (Correct answer)
- groupadd -u alice sudo
- gpasswd -d alice sudo
Correct answer: usermod -aG sudo alice
usermod -aG appends the specified group to the user's supplementary groups; omitting -a would replace all supplementary groups.
Which command displays the numeric UID and GID of the current user along with all supplementary group memberships?