AppArmor is a Mandatory Access Control (MAC) system deeply integrated into the Linux kernel and heavily utilised by Ubuntu. It acts as a strict security guard, binding programs to a specific set of rules (profiles) that dictate exactly which files they can read, write, or execute. If a program attempts to access a file outside of its assigned AppArmor profile, the kernel will instantly block the action, even if the user running the program is the root administrator.
While AppArmor is absolutely critical for server security, it is often the primary suspect when complex third-party software, custom database installations (like MySQL or MariaDB), or advanced virtualization tools (like Docker or KVM) mysteriously fail with “Permission Denied” errors despite having correct standard file permissions. To determine if AppArmor is the cause of your issue, you can completely disable the entire security module. Warning: This should only be done temporarily for troubleshooting purposes; running a production machine without AppArmor significantly reduces its security posture.
Disabling AppArmor via Systemd and Kernel Parameters
Because AppArmor is a kernel module, you cannot just uninstall it. You must disable its system service and instruct the GRUB bootloader to stop loading it into the kernel at startup.
- Open a Terminal window (Ctrl + Alt + T).
- First, stop the running service and disable it from launching on boot by typing the following commands (press Enter after each and provide your password):
sudo systemctl stop apparmorsudo systemctl disable apparmor - Next, you must remove the AppArmor parameters from the boot configuration. Open the GRUB file in a text editor:
sudo nano /etc/default/grub - Look for the line that begins with
GRUB_CMDLINE_LINUX_DEFAULT=. It will likely contain the wordsapparmor=1 security=apparmorinside the quotation marks. - Carefully delete
apparmor=1 security=apparmorfrom that line. Ensure you leave other parameters likequiet splashintact. - Add a new parameter to explicitly disable it. Add
apparmor=0inside the quotation marks. The final line should look something like:GRUB_CMDLINE_LINUX_DEFAULT="quiet splash apparmor=0" - Save the file (Ctrl + O, then Enter) and exit the editor (Ctrl + X).
Updating GRUB and Rebooting
You have edited the text file, but you must compile those changes into the actual bootloader before they take effect.
- In the terminal, run the following command to update GRUB:
sudo update-grub - Once the update is complete, restart your computer:
sudo reboot
Upon reboot, your Ubuntu system will start completely devoid of AppArmor protections. You can now test your failing software. If the software now works perfectly, you know you need to generate or modify a specific AppArmor profile for that application rather than leaving the entire system unprotected forever.