010-160 - LPI Linux Essentials Users and Group Management Questions and Answers — Questions and Answers
Question 1: A system administrator needs to create a new user named 'jdoe' and ensure their home directory is created at the same time. Which command will accomplish this?
- useradd jdoe
- useradd -m jdoe (Correct answer)
- useradd -h /home/jdoe jdoe
- adduser --create-home jdoe
Correct answer: useradd -m jdoe
The `useradd` command is used to create a new user. By default, it may not create the user's home directory. The `-m` option explicitly tells the command to create the user's home directory, which is typically located in `/home/`.
Question 2: Which file contains the user's encrypted password and password aging information?
- /etc/passwd
- /etc/group
- /etc/shadow (Correct answer)
- /etc/login.defs
Correct answer: /etc/shadow
The `/etc/shadow` file securely stores user password information. It contains the encrypted password hash and other details like password expiration policies. This file is readable only by the root user to enhance security.
Question 3: An administrator wants to add an existing user, 'sara', to the supplementary group 'developers'. Which of the following commands is the correct and safest way to do this without affecting her current group memberships?
- usermod -G developers sara
- usermod -g developers sara
- groupmod -a -m developers sara
- usermod -a -G developers sara (Correct answer)
Correct answer: usermod -a -G developers sara
The `usermod` command modifies a user's account. The `-G` option is used to specify a list of supplementary groups. Crucially, the `-a` (append) option must be used with `-G` to add the user to the new group without removing them from their existing supplementary groups.
Question 4: A project is complete and the user account 'tempuser' is no longer needed. A system administrator needs to delete the user and also remove their home directory and all its contents. Which command should be used?
- userdel tempuser
- userdel -r tempuser (Correct answer)
- rmuser tempuser --delete-home
- deluser tempuser
Correct answer: userdel -r tempuser
The `userdel` command is used to delete a user account. By itself, it may leave the user's home directory on the system. The `-r` option tells `userdel` to also remove the user's home directory and mail spool, ensuring a complete cleanup.
Question 5: What is the primary purpose of a user's primary group in Linux?
- To grant administrative privileges to the user.
- To define the user's default login shell.
- To set the default group ownership for files and directories the user creates. (Correct answer)
- To list all the groups the user can access.
Correct answer: To set the default group ownership for files and directories the user creates.
When a user creates a new file or directory, the system assigns group ownership. By default, this ownership is assigned to the user's primary group. Each user must belong to exactly one primary group.
Question 6: A user reports they cannot access a shared project file located at `/srv/data/report.docx`. The file's permissions are `rw-r-----` and its ownership is `jdoe:project`. The user is a member of the `project` group. What is the most likely reason they cannot access the file?
- The file is owned by another user.
- The user is not the owner of the file.
- The user needs to log out and log back in for group changes to take effect. (Correct answer)
- The `project` group does not have execute permissions on the file.
Correct answer: The user needs to log out and log back in for group changes to take effect.
When a user is added to a new group, the new group membership does not apply to their current active login session. The user must log out and log back in for the new group permissions to be applied to their session.
A system administrator needs to create a new user named 'jdoe' and ensure their home directory is created at the same time.
Which command will accomplish this?