SIMULATION -
Add users: user2, user3.
The Additional group of the two users: user2, user3 is the admin group Password: redhat
SIMULATION -
Add users: user2, user3.
The Additional group of the two users: user2, user3 is the admin group Password: redhat
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.
useradd -G admin user2 useradd -G admin user3 echo “redhat” | passwd --stdin user2 echo “redhat” | passwd --stdin user3
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 ~]#
for i in 2 3; do useradd -G admin user$i; echo "redhat"|passwd --stdin user$i; done
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
[root@abc ~]# passwd user2 --stdin Changing password for user user2. redhat passwd: all authentication tokens updated successfully. [root@abc ~]#
useradd user2 -G admin id user2 this syntax is vaild
usermod -aG admin Using just G makes it the default group
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.