RHCSA 8, Exam Practice Question 1 (User & Group Management)

What Should I know About The RHCSA Exam

Question

Add 3 users: harry, natasha, tom. The requirements: The Additional group of the two users: harry, Natasha is the admin group. The user: tom’s login shell should be non-interactive.

The question is based On The User & Group Management In The RHCSA, 8 Course on this website. If you have gone through this course, solving this wouldn’t be a problem.

RHCSA, 8 Course

User Management In Red Hat 8

Group Management In Red Hat 8

Ask Your Questions

Answer

1. Verify if the group admin exist, if it doesn’t exist, create the group

In my lab, it doesn’t exist, so, to create the admin group, use the command,

[root@lab02 ~]# groupadd admin

[root@lab02 ~]#
[root@lab02 ~]# cat /etc/group |grep admin

printadmin:x:995:
admin:x:1013:

[root@lab02 ~]#

2. Add the users, harry and Natasha first.

[root@lab02 ~]# useradd -G admin harry

[root@lab02 ~]#
[root@lab02 ~]# useradd -G admin Natasha

[root@lab02 ~]#

3. verify that the users are added to the admin group

[root@lab02 ~]# id harry

uid=1011(harry) gid=1014(harry) groups=1014(harry),1013(admin)
[root@lab02 ~]# id Natasha

uid=1012(Natasha) gid=1015(Natasha) groups=1015(Natasha),1013(admin)

[root@lab02 ~]#

4. create the user tom with a non interactive shell

[root@lab02 ~]# useradd -s /sbin/nologin/ tom

[root@lab02 ~]#

5. Verify the user, tom’s shell

[root@lab02 ~]# cat /etc/passwd |grep tom

tom:x:1013:1016::/home/tom:/sbin/nologin/
[root@lab02 ~]#

if you try to login with the user, tom. you will be denied because there is no login shell for tom

RHCSA 8 Exam Practice Question 1

Solution Summary

groupadd admin

cat /etc/group |grep admin

useradd -G admin harry

useradd -G admin Natasha

id harry

id Natasha

useradd -s /sbin/nologin/ tom

cat /etc/passwd |grep tom

You can also watch the Video on RHCSA 8 Exam Practice Question 1 by clicking the link below.

Linux Training – Full course

Your feedback is welcomed. If you love others, you will share with others

4 Comments

  1. if you add tom with the below command;

    [root@lab02 ~]# useradd -s /sbin/nologin/ tom

    you will get this error below

    Password:
    su: failed to execute /sbin/nologin/: Not a directory

    correct comma is [root@lab02 ~]# ‘useradd -s /sbin/nologin tom’ without the / after nologin coz it makes it a directory and not a shell

    • When you use tab completion, it’s most likely it add /, and that shouldn’t even be a problem. I wouldn’t know why your system is throwing that error, what Linux distribution and version are you using. Well, the most important thing is that you were able to get pass it and do what works for you. That’s the spirit. Great!!!

  2. To create users harry and natasha:
    useradd harry && useradd natasha
    To add harry and natasha to the admin group:
    usermod -G admin natasha && usermod -G admin harry
    To create tom as a non-interactive user:
    useradd -s /sbin/nologin tom

Leave a Reply

Your email address will not be published.


*