DEV Community

Cover image for 18.SElinux Installation and Configuration
Thu Kha Kyawe
Thu Kha Kyawe

Posted on

18.SElinux Installation and Configuration

Lab Information

Following a security audit, the xFusionCorp Industries security team has opted to enhance application and server security with SELinux. To initiate testing, the following requirements have been established for App server 1 in the Stratos Datacenter:

Install the required SELinux packages.

Permanently disable SELinux for the time being; it will be re-enabled after necessary configuration changes.

No need to reboot the server, as a scheduled maintenance reboot is already planned for tonight.

Disregard the current status of SELinux via the command line; the final status after the reboot should be disabled.
Enter fullscreen mode Exit fullscreen mode

Lab Solutions

🧭 Part 1: Lab Step-by-Step Guidelines

πŸ”Ή Step 1: Log in to Jump Host

ssh thor@jump_host.stratos.xfusioncorp.com

Password:

mjolnir123

πŸ”Ή Step 2: SSH into App Server 1

ssh tony@stapp01.stratos.xfusioncorp.com

Password:

Ir0nM@n

πŸ”Ή Step 3: Switch to root

sudo -i
Enter fullscreen mode Exit fullscreen mode

πŸ” Install Required SELinux Packages

On RHEL/CentOS-based systems, install:

yum install -y selinux-policy selinux-policy-targeted policycoreutils
Enter fullscreen mode Exit fullscreen mode

πŸ”§ Permanently Disable SELinux

πŸ”Ή Step 4: Edit SELinux config file

Open:

vi /etc/selinux/config
Enter fullscreen mode Exit fullscreen mode

Find:

SELINUX=enforcing

Change it to:

SELINUX=disabled

Save and exit.

πŸ”Ή Step 5: Verify configuration file

grep ^SELINUX= /etc/selinux/config
Enter fullscreen mode Exit fullscreen mode

Expected output:

SELINUX=disabled

⚠ Important

Do NOT reboot.

Lab explicitly states:

No reboot required

Ignore current runtime status

Only final state after reboot must be disabled

βœ… Final Checklist

βœ” SELinux packages installed
βœ” /etc/selinux/config modified
βœ” SELINUX=disabled set
βœ” No reboot performed
βœ” Completed on App Server 1 only

🧠 Part 2: Simple Step-by-Step Explanation (Beginner Friendly)

πŸ”Ή What is SELinux?

SELinux (Security-Enhanced Linux) adds:

Mandatory Access Control (MAC)

Fine-grained permission enforcement

Additional security layer beyond standard Unix permissions

πŸ”Ή Why install packages first?

Some systems may not have full SELinux utilities installed.

Installing ensures:

Configuration files exist

Required policies are present

Future re-enablement works correctly

πŸ”Ή What does SELINUX=disabled do?

This tells the system:

After next reboot, do not load SELinux.

Current runtime state does not matter.

Only config file matters for the lab.

πŸ”Ή Why no reboot?

Because:

Maintenance reboot is scheduled later

Lab checker reads configuration file, not runtime state

πŸ” Real-World Context

In production:

SELinux is usually set to enforcing

During migrations/testing, it may be temporarily disabled

Permanent disable requires reboot to take effect


Resources & Next Steps
πŸ“¦ Full Code Repository: KodeKloud Learning Labs
πŸ“– More Deep Dives: Whispering Cloud Insights - Read other technical articles
πŸ’¬ Join Discussion: DEV Community - Share your thoughts and questions
πŸ’Ό Let's Connect: LinkedIn - I'd love to connect with you

Credits
β€’ All labs are from: KodeKloud
β€’ I sincerely appreciate your provision of these valuable resources.

Top comments (0)