Play Redhat Linux 8.0 series | Manage local group accounts

Source of material: Redhat Linux 8.0 training materials "RH124", "RH134" and "RH294"

I have played Linux for 5-6 years, now I will review the RHCE training materials again, complete the experiment according to the guidance and share it with you.

Attach a summary post: Play Redhat Linux 8.0 series | collection


1 From the workstation, open an SSH session to servera as the student user.

[student@workstation ~]$ ssh student@servera
student@servera's password: 
Activate the web console with: systemctl enable --now cockpit.socket

This system is not registered to Red Hat Insights. See https://cloud.redhat.com/
To register this system, run: insights-client --register

Last login: Sat May 20 20:42:48 2023 from 172.16.190.227
[student@servera ~]$

2 On servera, use sudo to switch to root and inherit the complete environment of the root user.

[student@servera ~]$ sudo su -
[sudo] password for student: 
[root@servera ~]# 

3 Create a supplementary group of operators whose GID is 30000.

[root@servera ~]# groupadd -g 30000 operators
[root@servera ~]# 

4 Create admin as another supplementary group.

[root@servera ~]# groupadd admin
[root@servera ~]# 

5 Verify that both the supplementary groups operators and admin exist.

[root@servera ~]# tail /etc/group
gdm:x:42:
gnome-initial-setup:x:975:
sshd:x:74:
slocate:x:21:
tcpdump:x:72:
student:x:1000:
operator1:x:1001:
operator2:x:1002:
operators:x:30000:
admin:x:30001:
[root@servera ~]#

6 Make sure that users operator1, operator2, and operator3 belong to the group operators.

6.1 Add operator1, operator2 and operator3 to operators.

[root@servera ~]# usermod -aG operators operator1
[root@servera ~]# usermod -aG operators operator2
[root@servera ~]# usermod -aG operators operator3
[root@servera ~]# 

6.2 Confirm that the users have been successfully added to the group.

[root@servera ~]# id operator1
uid=1001(operator1) gid=1001(operator1) groups=1001(operator1),30000(operators)
[root@servera ~]# id operator2
uid=1002(operator2) gid=1002(operator2) groups=1002(operator2),30000(operators)
[root@servera ~]# id operator3
uid=1003(operator3) gid=1003(operator3) groups=1003(operator3),30000(operators)
[root@servera ~]# 

7 Make sure that users sysadmin1, sysadmin2, and sysadmin3 belong to the group admin. Enables administrative privileges for all members of the admin group. Verify that any member of the admin group can run administrative commands.

7.1 Add sysadmin1, sysadmin2 and sysadmin3 to admin.

[root@servera ~]# usermod -aG admin sysadmin1
[root@servera ~]# usermod -aG admin sysadmin2
[root@servera ~]# usermod -aG admin sysadmin3
[root@servera ~]# 

7.2 Confirm that the users were successfully added to the group.

[root@servera ~]# id sysadmin1
uid=1004(sysadmin1) gid=1004(sysadmin1) groups=1004(sysadmin1),30001(admin)
[root@servera ~]# id sysadmin2
uid=1005(sysadmin2) gid=1005(sysadmin2) groups=1005(sysadmin2),30001(admin)
[root@servera ~]# id sysadmin3
uid=1006(sysadmin3) gid=1006(sysadmin3) groups=1006(sysadmin3),30001(admin)
[root@servera ~]# 

7.3 Check /etc/group to verify supplementary group membership.

[root@servera ~]# tail /etc/group
tcpdump:x:72:
student:x:1000:
operator1:x:1001:
operator2:x:1002:
operators:x:30000:operator1,operator2,operator3
admin:x:30001:sysadmin1,sysadmin2,sysadmin3
operator3:x:1003:
sysadmin1:x:1004:
sysadmin2:x:1005:
sysadmin3:x:1006:
[root@servera ~]#

7.4 Create the /etc/sudoers.d/admin file so that members of admin have full administrative privileges.

[root@servera ~]# echo "%admin ALL=(ALL) ALL" >> /etc/sudoers.d/admin
[root@servera ~]# 

7.5 Switch to sysadmin1 (a member of admin), and verify that you can run sudo commands as sysadmin1.

[root@servera ~]# su - sysadmin1
[sysadmin1@servera ~]$ sudo cat /etc/sudoers.d/admin

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

    #1) Respect the privacy of others.
    #2) Think before you type.
    #3) With great power comes great responsibility.

[sudo] password for sysadmin1: 
%admin ALL=(ALL) ALL
[sysadmin1@servera ~]$

7.6 Exit from the sysadmin1 user's shell to return to the root user's shell.

[sysadmin1@servera ~]$ exit
logout
[root@servera ~]# 

7.7 Exit from the root user's shell to return to the student user's shell.

[root@servera ~]# exit
logout
[student@servera ~]$

7.8 Log out from servera.

[student@servera ~]$ exit
logout
Connection to servera closed.
[student@workstation ~]$

Guess you like

Origin blog.csdn.net/guolianggsta/article/details/131305520