RHCSA Rapid Track
Course update
An updated version of this course is available that uses a newer version of Red Hat Enterprise Linux in the lab environment. Therefore, the RHEL 9.0 version of the lab environment will retire on December 31, 2024. Please complete any work in this lab environment before it is removed on December 31, 2024. For the most up-to-date version of this course, we recommend moving to the RHEL 9.3 version.
In this lab, you manage SELinux modes, both temporarily and persistently.
Outcomes
View and set the current SELinux mode.
As the student user on the workstation machine, use the lab command to prepare your system for this exercise.
This command prepares your environment and ensures that all required resources are available.
[student@workstation ~]$ lab start selinux-opsmode
Instructions
On the
workstationmachine, use thesshcommand to log in to theserveramachine as thestudentuser and then switch to therootuser.[student@workstation ~]$
ssh student@servera...output omitted... [student@servera ~]$sudo -i[sudo] password for student:student[root@servera ~]#Change the default SELinux mode to permissive.
Use the
getenforcecommand to verify the current SELinux mode on theserveramachine.[root@servera ~]#
getenforceEnforcingUse the
vim /etc/selinux/configcommand to edit the configuration file. Change theSELINUXparameter fromenforcingtopermissivemode.[root@servera ~]#
vim /etc/selinux/configUse the
grepcommand to confirm that theSELINUXparameter displays thepermissivemode.[root@servera ~]#
grep '^SELINUX' /etc/selinux/configSELINUX=permissiveSELINUXTYPE=targetedUse the
setenforcecommand to change theSELINUXparameter to thepermissivemode and verify the change.[root@servera ~]#
setenforce 0[root@servera ~]#getenforcePermissive
Change the default SELinux mode back to the
enforcingmode in the configuration file.Use the
vim /etc/selinux/configcommand to edit the configuration file. Change theSELINUXparameter frompermissivetoenforcingmode.[root@servera ~]#
vim /etc/selinux/configUse the
grepcommand to confirm that theSELINUXparameter sets theenforcingmode on booting.[root@servera ~]#
grep '^SELINUX' /etc/selinux/configSELINUX=enforcingSELINUXTYPE=targeted
Set the SELinux mode to
enforcingon the command line. Reboot theserveramachine and verify the SELinux mode.Use the
setenforcecommand to set the current SELinux mode to theenforcingmode. Use thegetenforcecommand to confirm that SELinux is set to theenforcingmode.[root@servera ~]#
setenforce 1[root@servera ~]#getenforceEnforcingReboot the
serveramachine to implement the persistent configuration.[root@servera ~]#
systemctl rebootConnection to servera closed by remote host. Connection to servera closed. [student@workstation ~]$Log in to the
serveramachine and verify the SELinux mode.[student@workstation ~]$
ssh student@servera...output omitted... [student@servera ~]$sudo -i[sudo] password for student:student[root@servera ~]#getenforceEnforcing
Return to the
workstationmachine as thestudentuser.[root@servera ~]#
exitlogout [student@servera ~]$exitlogout Connection to servera closed. [student@workstation ~]$
This concludes the section.