brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: Permission denied with correct permissions often means AppArmor said no

Permissions
~/tips/tip-permissions-apparmor-denied-log

sudo journalctl -k --since '10 min ago' | grep 'apparmor="DENIED"'

Finds AppArmor denials in the kernel log when chmod and chown look right.

You checked the owner, the mode and every folder on the path, and the service still gets Permission denied. On Ubuntu, a confined program is also limited by its AppArmor profile, whatever the file permissions say.

Look for denials in the kernel log:

sudo journalctl -k --since '10 min ago' | grep 'apparmor="DENIED"'

A line looks something like apparmor="DENIED" operation="open" profile="/usr/sbin/nginx" name="/srv/media/photo.jpg" requested_mask="r". The profile tells you which program was stopped, name which file, and the mask what it wanted: r for read, w for write.

I’d suspect this first when data has moved to a new place, like /srv or a second disk, because profiles usually allow only the standard paths. Normal permissions can’t fix that. You either add the path to a local override for the profile, such as a file in /etc/apparmor.d/local/, or keep the data where the profile expects it.

To see which profiles are active, run sudo aa-status. Snap packages are confined as well, and their denials look the same with a profile name starting with snap..

One trap: explicit deny rules in a profile block without writing anything to the log. If the log is empty but you still suspect AppArmor, look at the profile itself.

Further reading: Ubuntu Server docs: AppArmor

More Permissions tips sudo su -s /bin/bash www-data sudo setfacl -R -d -m g:media:rwX /srv/media sudo cp -r /srv/site /srv/site.r ls -ln /srv/data newgrp media All Permissions tips (30) All topics

Link