fbpx Master Advanced Linux Security with SELinux and AppArmor | Certificação Linux

Mastering Advanced Linux Security: SELinux, AppArmor, and Audits

📅 07/19/2026 ⏱ 3 min ✍️ Uira Ribeiro
Mastering Advanced Linux Security: SELinux, AppArmor, and Audits
Exam Pass App — mais de 7.000 questões LPI, offline, em 5 idiomas, disponível no Android e na App Store
Available on
Google Play
Available on
App Store

Security is a constant concern for system administrators and DevOps engineers. This article explores advanced techniques for securing Linux environments, focusing on SELinux, AppArmor, and security audits. We go beyond basic commands and dive into the "why" and "how" these tools work, providing practical and configurable examples.

Introduction to SELinux

The Security-Enhanced Linux (SELinux) is an implementation of mandatory access control (MAC) security policies for Linux. It provides a mechanism to support multiple security policies, allowing more granular control over system resources.

Configuring SELinux

To enable and configure SELinux, you need to edit the /etc/selinux/config file:

SELINUX=enforcing
SELINUXTYPE=targeted

Restart the system to apply the changes. To check the SELinux status, use the command:

getenforce
# Output esperado: Enforcing

Creating Custom Policies

You can create custom policies for specific applications. For example, to allow an application to access a restricted directory:

chcon -t httpd_sys_content_t /path/to/directory
# Isso define o contexto de segurança do diretório para ser acessível pelo Apache

Introduction to AppArmor

AppArmor is another MAC security tool for Linux, focused on confining programs to prevent unwanted behavior. It uses profiles to define permissions.

Configuring AppArmor

To enable AppArmor, you can use:

sudo systemctl enable apparmor
sudo systemctl start apparmor

Creating an AppArmor Profile

A typical AppArmor profile for a web service can be configured like this:

sudo aa-genprof /usr/sbin/apache2
# Isso gera e aplica um perfil para o Apache

Security Audits

Security audits are crucial for identifying vulnerabilities and ensuring compliance. Tools like auditd can be used to monitor system activities.

Configuring Auditd

To configure auditd, edit the /etc/audit/auditd.conf file and define:

[auditd]
log_file = /var/log/audit/audit.log
log_group = root

Start the service with:

sudo systemctl start auditd
sudo systemctl enable auditd

Creating Audit Rules

To create an audit rule to monitor binary executions, use:

sudo auditctl -a exit,always -S execve -k execve-watch
# Isso monitora todas as execuções de binários e marca com 'execve-watch'

Why This Matters / When to Use

Implementing SELinux, AppArmor, and audits is crucial in production environments to protect against internal and external threats. Use these tools when you need detailed access control and continuous monitoring of system activities.

Connection with LPI/CompTIA Certifications

Mastering these advanced security techniques is essential for obtaining LPI and CompTIA certifications, which value deep knowledge in Linux systems security. Preparing with these concepts not only strengthens your skills but also improves your chances of success in certifications.

Uira Ribeiro

Prof. Uirá Ribeiro

Chair do Board do Linux Professional Institute

After years of watching professionals waste hours on simple tasks because they didn't know the right Linux tools, I decided to teach.
Today I'm the author of most of LPI's official Learning Materials and mentor to over 14,000 certified students.

See my full story →

That was just one piece. The course teaches the whole path — from your first command to exam day.

Certificação Linux — a plataforma líder em certificações Linux no Brasil
WhatsApp