Exam EX200 All QuestionsBrowse all questions from this exam
Question 82

SIMULATION -

According the following requirements to create user, user group and the group members:

- A group named admin.

- A user named mary, and belong to admin as the secondary group.

- A user named alice, and belong to admin as the secondary group.

- A user named bobby, bobby's login shell should be non-interactive. Bobby not belong to admin as the secondary group.

Mary, Alice, bobby users must be set "password" as the user's password.

    Correct Answer:

    To fulfill the given requirements, follow these steps carefully. First, ensure that a group named 'admin' is created. Then, create users with the specified names and attributes, placing Mary and Alice in the 'admin' group as their secondary group. Bobby should have a non-interactive shell and not belong to the 'admin' group. Finally, set the password 'password' for all the users. Here's how you can achieve this on a Linux system: 1) Create the 'admin' group using 'groupadd admin'. 2) Create the user 'mary' and add her to the 'admin' group as a secondary group using 'useradd -G admin mary'. 3) Create the user 'alice' and add her to the 'admin' group as a secondary group using 'useradd -G admin alice'. 4) Create the user 'bobby' with a non-interactive login shell using 'useradd -s /sbin/nologin bobby'. 5) Set the password 'password' for 'mary' using 'echo password | passwd --stdin mary'. 6) Set the password 'password' for 'alice' using 'echo password | passwd --stdin alice'. 7) Set the password 'password' for 'bobby' using 'echo password | passwd --stdin bobby'. Note that the 'useradd' commands for Mary and Alice use the '-G' option to specify the secondary group, while the command for Bobby specifies the shell using '-s'. The password is set using the 'passwd' command piped with 'echo' and '--stdin' to set 'password' as the password for each user.

Discussion
gaven186

'useradd' without option '-a' means the new assigned group is replacing the previous group assignment. '-a' means 'append' to enable a secondary group assignment. I think '-a' is necessary to fit the requirement. # groupadd admin # useradd -aG admin mary # useradd -aG admin alice # useradd -s /sbin/nologin bobby

ly01

there is no -a switch in useradd... and you are creating the users from scratch... just make id "username" to check