Linux apparmor
Give each program clear limits
Imagine a shared house where a program should be able to open its own files but not every file on the computer. AppArmor lets Linux apply extra rules to a program, such as which paths it may read or change. The program still runs normally when its actions fit those rules. The kernel checks the profile alongside ordinary user and group permissions.
Those rules are called an AppArmor profile. AppArmor is a Linux Security Module (LSM), a framework the kernel uses to apply security policies. Profiles commonly attach to a program through its executable path, and can refer to distribution-provided abstractions or variables. The extra rules are mandatory access control: they can block an action that ordinary file permissions would otherwise allow. SELinux uses a different model based on labels. Both use the Linux Security Modules framework; the active policy and installed profiles depend on the distribution and its configuration.
Start by checking which profiles the system has loaded:
sudo aa-status
The status command shows what is active; installing AppArmor tools alone does not confine every program. A program needs an applicable profile in enforcement mode.
Test a profile without blocking normal work
In enforce mode, AppArmor blocks operations that the profile denies and may write a record to the audit or kernel log. Complain mode generally allows an operation that lacks an allowance and logs the attempt instead. An explicit deny rule can still block an operation in complain mode. This mode is useful while exercising an application and collecting evidence, but it cannot prove a profile covers every legitimate workflow. Test the features and inputs people actually use.
With AppArmor utilities installed, the commands below switch an example profile into complain mode and then restore enforcement:
sudo aa-complain /etc/apparmor.d/usr.bin.example
sudo aa-enforce /etc/apparmor.d/usr.bin.example
The profile path and command arguments can vary by distribution. Check the local help for aa-complain and aa-enforce to learn whether they expect an executable path or a profile name. Complain mode stops blocking many policy violations, so it can change both security and application behavior.
Update rules with a specific reason
Profiles commonly live in /etc/apparmor.d/. After editing one, load the new policy with apparmor_parser or the reload method documented by the distribution. A successful parse means the syntax was accepted; it does not prove the rules are safe or complete. Review audit events, test expected features, and confirm important restrictions still work.
Depending on kernel and policy support, AppArmor can control file access, capabilities, signals, networking, and other actions. It works alongside ordinary file permissions, least-privilege accounts, and secure application practices. If an application fails after a profile change, identify the active profile and match the denial in the logs to the attempted operation. Add a narrow rule only when the operation belongs to the program's intended behavior. A broad filesystem allowance can hide the error while removing much of the profile's protection.




