Before diving deeper into SELinux, there are several basic Linux skills you must master first: CLI and shell, systemd service management, file permissions, and the dnf package manager. This episode also guides you through setting up a safe lab environment, installing SELinux userspace tools, and verifying that SELinux is active on your system.

Welcome to the Learn SELinux series! This series will take you from zero to production-ready in understanding SELinux (Security-Enhanced Linux) — a Linux Security Module that provides Mandatory Access Control (MAC) based on Type Enforcement. There are 23 episodes total that will guide you from understanding your first denial to managing secure, audited, and production-ready policies that can be used in the real world.
Before you type your first getenforce or read an AVC log containing denials, there are some basic skills and tools you need to have first. Why are these prerequisites so important? SELinux is not a standalone feature — it runs on top of the Linux foundation you already know: file permissions, systemd, package manager, and CLI. Imagine wanting to become an airplane pilot but not understanding how to read cockpit instruments — no matter how good the plane is, takeoff will still be difficult.
Episode 0 will be your roadmap: making sure your skills are sufficient, setting up a safe lab environment with a distro that has SELinux enabled, installing userspace tools, and then verifying that your system is ready. Once this episode is complete, you'll be truly ready to move on to episode 1, which covers the history and background of why SELinux exists.
Let's start with skills. Without these skills, even the most sophisticated tools will be useless.
You will spend almost all of this series at the terminal. SELinux is managed through CLI commands such as semanage, sesearch, restorecon, and audit2allow — without comfort on the command line, all these tools will just feel like meaningless magic spells. Make sure you're comfortable with:
ls, cd, cat, grep, less, tail, and find.| pipelines to combine small commands into one complex job.You don't need to become a script master. Just reach the level of "I can write commands, read output, and inspect errors without panicking". The rest will come naturally as you progress through this series.
SELinux doesn't work alone — it depends heavily on the services underneath it, and almost all of those services are managed by systemd. You'll interact often with services like auditd, sshd, and httpd in the following episodes. Master these four basic operations:
| Command | Function |
|---|---|
systemctl status <service> | View the status, PID, and recent logs of a service |
systemctl start <service> | Start a service |
systemctl enable --now <service> | Activate a service and make it start automatically at boot |
systemctl restart <service> | Restart a service after configuration changes |
One thing to note from now on: in the SELinux world, every service process runs in a domain — a term you'll encounter very often starting in episode 2. systemd and SELinux are two worlds that overlap, so understand both.
This is the most important foundation. Before understanding SELinux's MAC (Mandatory Access Control), you need to understand first Linux's built-in DAC (Discretionary Access Control) — the rwx permissions for user, group, and other that you've been using with chmod and chown. Remember one principle: SELinux works on top of DAC, not replacing it. An access must pass through two layered gates: DAC first, then MAC.
chmod 750 /srv/www
chown arman:devops /srv/www
umask 022chmod 750 means the owner has full access, the group can read and execute, and others have no access. umask 022 ensures new files aren't accidentally left wide open. If these concepts still feel unfamiliar, take some time to review Linux permission material before continuing — because in episode 1 we'll discuss why DAC alone is not enough for a truly secure system.
This series focuses on the Red Hat ecosystem, so dnf will be your daily companion. You'll install SELinux userspace tools, update policy packages, and sometimes install additional policy packages for specific applications. Also, understand how to view processes with ps aux and kill processes with kill — because SELinux context labels attach to processes, not to commands.
| Command | Function |
|---|---|
sudo dnf install <package> | Install a package along with its dependencies |
sudo dnf update | Update all system packages |
ps aux | View all running processes |
kill <pid> | Stop a process by PID |
Now that the basic skills are ready, it's time to set up the environment where you'll practice. This decision matters because it determines how representative your learning experience is of production conditions.
SELinux is the most mature feature in the Red Hat ecosystem. Distro recommendations for this series, in order of preference:
It's important to understand: distros outside the Red Hat family such as Ubuntu and Debian use AppArmor by default, not SELinux. Enabling SELinux there requires additional configuration steps and isn't recommended for learning — focus on one ecosystem for consistency.
Best practice: never learn SELinux on your main host or on a production server. Use a Virtual Machine (VM). Inside the VM, you're free to switch the enforcing mode to permissive, relabel file contexts however you like, and even break the system to the point where it can't boot — and none of it will affect your main computer.
One habit that will save you a lot: create a snapshot before experimenting. A wrong label with chcon or a full relabel with fixfiles can render the system non-functional — and the snapshot is your undo button. If you break something, just restore it.
The kernel is just the enforcer; the tools for reading policies, changing contexts, and troubleshooting all live in the userspace packages. After a clean system install, install the following packages:
sudo dnf install -y selinux-policy-targeted policycoreutils-python-utils setools-console auditHere's the role of each package — get to know them because they'll accompany you throughout this series:
| Package | Role |
|---|---|
selinux-policy-targeted | The default (targeted) policy containing the protection rules |
policycoreutils-python-utils | Core tools: semanage, audit2allow, restorecon |
setools-console | Policy analysis tools: sesearch, seinfo |
audit | Audit system: auditd and ausearch, the source of AVC logs |
After the install finishes, make sure the auditd service is running because SELinux denial logs are written through it:
sudo systemctl enable --now auditdTime to make sure everything is ready. First, check the currently running SELinux mode:
getenforceOutput Enforcing means SELinux is active and blocking accesses not allowed by the policy. Next, view the full status:
sestatusSELinux status: enabled
SELinuxfs mount: /sys/fs/selinux
SELinux root directory: /etc/selinux
Loaded policy name: targeted
Current mode: enforcing
Mode from config file: enforcing
Policy MLS status: enabled
Memory protection checking: actual (secure)
Max kernel policy version: 34Three lines you must pay attention to: SELinux status: enabled (the kernel is active), Loaded policy name: targeted (the loaded policy), and Current mode: enforcing (the mode currently running). If all three match the example above, your environment is officially ready.
getenforce doesn't even exist. Make sure you're on an RHEL/Fedora-family distro.semanage or sesearch aren't found, you haven't installed policycoreutils-python-utils and setools-console.In this episode 0, we've laid a solid foundation for the entire journey: making sure you master basic Linux skills (CLI, systemd, permissions, dnf), choosing a Red Hat-family distro with SELinux enabled, setting up a safe VM lab, installing userspace tools, and verifying that SELinux runs in enforcing mode.
Key points to take with you:
semanage, sesearch, audit2allow, ausearch) are your main weapons — make sure they're installed.getenforce and sestatus.Remember, the Learn SELinux series consists of 23 episodes that build on each other. Make sure your environment is ready, because in the next episode 1 we'll discuss the history, background, and why the world needs SELinux — from the limitations of DAC, how NSA together with Red Hat birthed this project in the early 2000s, to its integration into the Linux 2.6 kernel in 2003. Stay motivated, because the SELinux learning journey has only just begun!