See what is running
sudo aa-status
systemctl status apparmor
You should see profiles in enforce and sometimes complain. Complain logs denials without blocking; enforce blocks.
Find a service profile
Profiles live under /etc/apparmor.d/. Example check for a daemon:
ls /etc/apparmor.d/ | head
sudo aa-status | grep -i nginx
Safe tighten loop
- Put the profile in complain:
sudo aa-complain /etc/apparmor.d/USR.SBIN.NGINX(use the real profile path). - Exercise the service the way production does.
- Read denials:
sudo journalctl -k | grep apparmor | tailorsudo dmesg | grep apparmor. - Adjust the profile or use
aa-logprof, thensudo aa-enforce …and re-test.
When AppArmor is not the first lever
If the server carries hundreds of unused packages, start with removal and SSH/firewall. Removing what the server never uses shrinks what AppArmor even has to cover.
Related guides: SSH hardening on Ubuntu 22.04 · firewall with ufw · removing unused packages.
FAQ
Is AppArmor the same as SELinux?
No. Ubuntu uses AppArmor by default; RHEL-family systems usually use SELinux. Do not mix advice blindly.
Should I set everything to enforce overnight?
No. Profile applications in complain mode first, read the denials, then enforce when the app still works.
Does removing packages relate to AppArmor?
Yes indirectly: fewer services means fewer profiles to care about.
Next
Start with Inaabi Scan, then Subscribe to Inaabi Tune at $20 per server per month. Index: all Inaabi guides.
MinakiLabs