Permissions & Security (Chmod/Chown/ACLs/SELinux/AppArmor)
Stop getting blocked by SELinux when moving logs to non-standard paths
🧩 The Challenge
You finally moved your application logs to a custom mount point, but now your logging daemon refuses to write to them. It’s infuriating when file permissions look perfect but everything is still denied by the kernel.
💡 The Fix
Use semanage to copy the security context from the default logging directory to your new home. This keeps the policy happy without having to set the whole system to permissive mode.
semanage fcontext -a -e /var/log /path/to/custom/logs
restorecon -Rv /path/to/custom/logs
⚙️ Why It Works
Copying the context tells the kernel that files in your new location are functionally equivalent to standard log files, so the existing security policy automatically permits the access. Forgetting to run restorecon after adding the rule is a common mistake that leaves you scratching your head.
🚀 Pro-Tip: Run ls -Z before and after to actually see the context change happen in real time.
Linux Tips & Tricks | © ngelinux.com | 8/27/2026
