EX200 Exam QuestionsBrowse all questions from this exam

EX200 Exam - Question 22


SIMULATION -

Add users: user2, user3.

The Additional group of the two users: user2, user3 is the admin group Password: redhat

Show Answer
Correct Answer:

To add users, ensure they are members of the admin group and set their passwords, you need to follow these steps: First, create the users and add them to the 'admin' group using the '-G' option to specify the additional group. Then, set their passwords. Here are the commands you should use: `# useradd -G admin user2`, `# useradd -G admin user3`, `# echo 'redhat' | passwd --stdin user2`, and `# echo 'redhat' | passwd --stdin user3`. Alternatively, you could manually set the passwords individually using `# passwd user2` and entering 'redhat' as prompted, and similarly for user3. This ensures both users are created, added to the correct additional group, and have their passwords set.

Discussion

7 comments
Sign in to comment
RedQuasar
Dec 12, 2020

useradd -G admin user2 useradd -G admin user3 echo “redhat” | passwd --stdin user2 echo “redhat” | passwd --stdin user3

gunwantk
Oct 15, 2021

Make steps simple, more complex commands are confusing, [root@station ~]# cat /etc/group | grep -i admin [root@station ~]# [root@station ~]# groupadd admin [root@station ~]# [root@station ~]# useradd user2 [root@station ~]# passwd user2 [root@station ~]# useradd user3 [root@station ~]# passwd user3 [root@station ~]# [root@station ~]# [root@station ~]# id user2 uid=1004(user2) gid=1007(user2) groups=1007(user2) [root@station ~]# id user3 uid=1005(user3) gid=1008(user3) groups=1008(user3) [root@station ~]# [root@station ~]# usermod -a -G admin user2 [root@station ~]# usermod -a -G admin user3 [root@station ~]# [root@station ~]# id user3 uid=1005(user3) gid=1008(user3) groups=1008(user3),1006(admin) [root@station ~]# id user2 uid=1004(user2) gid=1007(user2) groups=1007(user2),1006(admin) [root@station ~]#

ionix
Mar 31, 2021

for i in 2 3; do useradd -G admin user$i; echo "redhat"|passwd --stdin user$i; done

juliansaccount
Sep 28, 2020

usermod -aG admin Using just G makes it the default group

cytron
Nov 9, 2020

This is correct when you modifying existing user and adding more supplementary groups but if you creating new user you can use just -G for supplementary/additional group.

sugisho
Jul 13, 2021

useradd user2 -G admin id user2 this syntax is vaild

sugisho
Jul 23, 2021

[root@abc ~]# passwd user2 --stdin Changing password for user user2. redhat passwd: all authentication tokens updated successfully. [root@abc ~]#

Lazylinux
Jul 4, 2024

useradd -m -G admin user2 useradd -m -G admin user3 verify lid user2 lid user3 Now passwd passwd user2 passwd user3 Verify su user2 > should allow access su user3 > should allow access