{
    "mode": "man",
    "parameter": "apparmor",
    "section": "7",
    "url": "https://www.chedong.com/phpMan.php/man/apparmor/7/json",
    "generated": "2026-10-04T13:31:42Z",
    "sections": {
        "NAME": {
            "content": "AppArmor - kernel enhancement to confine programs to a limited set of resources.\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "AppArmor is a kernel enhancement to confine programs to a limited set of resources.\nAppArmor's unique security model is to bind access control attributes to programs rather than\nto users.\n\nAppArmor confinement is provided via profiles loaded into the kernel via apparmorparser(8),\ntypically through the apparmor.service systemd unit, which is used like this:\n\n# systemctl start apparmor\n# systemctl reload apparmor\n\nAppArmor can operate in two modes: enforcement, and complain or learning:\n\n•   enforcement  -   Profiles  loaded  in  enforcement mode will result in enforcement of the\npolicy defined in the profile as well as reporting policy violation attempts to syslogd.\n\n•   complain - Profiles loaded in  \"complain\" mode will not enforce policy.  Instead, it will\nreport policy violation attempts. This mode is convenient  for  developing  profiles.  To\nmanage   complain   mode   for  individual  profiles  the  utilities  aa-complain(8)  and\naa-enforce(8) can be used.  These utilities take a program name as an argument.\n\nProfiles are traditionally stored in files  in  /etc/apparmor.d/  under  filenames  with  the\nconvention  of  replacing  the  / in pathnames with . (except for the root /) so profiles are\neasier to manage (e.g. the /usr/sbin/nscd profile would be named usr.sbin.nscd).\n\nProfiles are applied to a process at exec(3) time  (as  seen  through  the  execve(2)  system\ncall):  once  a  profile  is  loaded for a program, that program will be confined on the next\nexec(3). If a process is already running under a profile, when one replaces that  profile  in\nthe kernel, the updated profile is applied immediately to that process.  On the other hand, a\nprocess that is already running unconfined cannot be confined.\n\nAppArmor  supports  the Linux kernel's securityfs filesystem, and makes available the list of\nthe profiles currently loaded; to mount the filesystem:\n\n# mount -tsecurityfs securityfs /sys/kernel/security\n$ cat /sys/kernel/security/apparmor/profiles\n/usr/bin/mutt\n/usr/bin/gpg\n...\n\nNormally, the initscript will mount securityfs if it has not already been done.\n\nAppArmor also restricts what privileged operations a confined process may  execute,  even  if\nthe process is running as root. A confined process cannot call the following system calls:\n\ncreatemodule(2) deletemodule(2) initmodule(2) ioperm(2)\niopl(2) ptrace(2) reboot(2) setdomainname(2)\nsethostname(2) swapoff(2) swapon(2) sysctl(2)\n",
            "subsections": [
                {
                    "name": "Complain mode",
                    "content": "Instead  of  denying  access  to  resources the profile does not have a rule for AppArmor can\n\"allow\" the access and log a message for the operation  that  triggers  it.  This  is  called\ncomplain  mode.  It is important to note that rules that are present in the profile are still\napplied, so allow rules will still quiet or force audit messages, and deny rules  will  still\nresult  in  denials and quieting of denial messages (see Turn off deny audit quieting if this\nis a problem).\n\nComplain mode can be used to develop profiles incrementally as an application  is  exercised.\nThe  logged  accesses  can  be  added  to  the  profile  and then can the application further\nexcercised to discover further  additions  that  are  needed.  Because  AppArmor  allows  the\naccesses the application will behave as it would if AppArmor was not confining it.\n\nWarning  complain  mode does not provide any security, only auditing, while it is enabled. It\nshould not be used in a hostile environment or bad behaviors may be logged and added  to  the\nprofile as if they are resource accesses that should be used by the application.\n\nNote  complain mode can be very noisy with new or empty profiles, but with developed profiles\nmight not log anything if the profile covers the application behavior well.  See  Audit  Rate\nLimiting if complain mode is generating too many log messages.\n\nTo  set a profile and any children or hat profiles the profile may contain into complain mode\nuse\n\naa-complain /etc/apparmor.d/<the-application>\n\nTo manually set a specific profile in complain  mode,  add  the  \"complain\"  flag,  and  then\nmanually reload the profile:\n\nprofile foo flags=(complain) { ... }\n\nNote that the \"complain\" flag must also be added manually to any hats or children profiles of\nthe profile or they will continue to use the previous mode.\n\nTo enable complain mode globally, run:\n\necho -n complain > /sys/module/apparmor/parameters/mode\n\nor to set it on boot add:\n\napparmor.mode=complain\n\nas a kernel boot paramenter.\n\nWarning Setting complain mode gloabally disables all apparmor security protections. It can be\nuseful  during  debugging or profile development, but setting it selectively on a per profile\nbasis is safer.\n"
                }
            ]
        },
        "ERRORS": {
            "content": "When a confined process tries to access a file it does not have  permission  to  access,  the\nkernel will report a message through audit, similar to:\n\naudit(1386511672.612:238): apparmor=\"DENIED\" operation=\"exec\"\nparent=7589 profile=\"/tmp/sh\" name=\"/bin/uname\" pid=7605\ncomm=\"sh\" requestedmask=\"x\" deniedmask=\"x\" fsuid=0 ouid=0\n\naudit(1386511672.613:239): apparmor=\"DENIED\" operation=\"open\"\nparent=7589 profile=\"/tmp/sh\" name=\"/bin/uname\" pid=7605\ncomm=\"sh\" requestedmask=\"r\" deniedmask=\"r\" fsuid=0 ouid=0\n\naudit(1386511772.804:246): apparmor=\"DENIED\" operation=\"capable\"\nparent=7246 profile=\"/tmp/sh\" pid=7589 comm=\"sh\" pid=7589\ncomm=\"sh\" capability=2  capname=\"dacoverride\"\n\nThe  permissions  requested  by  the process are described in the operation= and deniedmask=\n(for files - capabilities etc. use a slightly different log format).  The \"name\" and  process\nid  of the running program are reported, as well as the profile name including any \"hat\" that\nmay be active, separated by \"//\". (\"Name\" is in quotes, because the process name  is  limited\nto 15 bytes; it is the same as reported through the Berkeley process accounting.)\n\nFor  confined  processes  running  under  a  profile  that  has been loaded in complain mode,\nenforcement will not take place and the log messages reported to audit will be of the form:\n\naudit(1386512577.017:275): apparmor=\"ALLOWED\" operation=\"open\"\nparent=8012 profile=\"/usr/bin/du\" name=\"/etc/apparmor.d/tunables/\"\npid=8049 comm=\"du\" requestedmask=\"r\" deniedmask=\"r\" fsuid=1000 ouid=0\n\naudit(1386512577.017:276): apparmor=\"ALLOWED\" operation=\"open\"\nparent=8012 profile=\"/usr/bin/du\" name=\"/etc/apparmor.d/tunables/\"\npid=8049 comm=\"du\" requestedmask=\"r\" deniedmask=\"r\" fsuid=1000 ouid=0\n\nIf the userland auditd is not running, the kernel will send audit events to klogd; klogd will\nsend the messages to syslog, which will log  the  messages  with  the  KERN  facility.  Thus,\nREJECTING   and   PERMITTING   messages   may   go   to  either  /var/log/audit/audit.log  or\n/var/log/messages, depending upon local configuration.\n",
            "subsections": []
        },
        "DEBUGGING": {
            "content": "AppArmor provides a few  facilities  to  log  more  information,  which  can  help  debugging\nprofiles.\n",
            "subsections": [
                {
                    "name": "Enable debug mode",
                    "content": "When  debug  mode  is  enabled,  AppArmor will log a few extra messages to dmesg (not via the\naudit subsystem). For example, the logs will tell  whether  environment  scrubbing  has  been\napplied.\n\nTo enable debug mode, run:\n\necho 1 > /sys/module/apparmor/parameters/debug\n\nor to set it on boot add:\n\napparmor.debug=1\n\nas a kernel boot paramenter.\n"
                },
                {
                    "name": "Turn off deny audit quieting",
                    "content": "By  default,  operations that trigger \"deny\" rules are not logged.  This is called deny audit\nquieting.\n\nTo turn off deny audit quieting, run:\n\necho -n noquiet >/sys/module/apparmor/parameters/audit\n\nor to set it on boot add:\n\napparmor.audit=noquiet\n\nas a kernel boot paramenter.\n"
                },
                {
                    "name": "Force audit mode",
                    "content": "AppArmor can log a message for every operation that triggers a rule configured in the policy.\nThis is called force audit mode.\n\nWarning! Force audit mode can be extremely noisy even for a single profile,  let  alone  when\nenabled globally.\n\nTo set a specific profile in force audit mode, add the \"audit\" flag:\n\nprofile foo flags=(audit) { ... }\n\nTo enable force audit mode globally, run:\n\necho -n all > /sys/module/apparmor/parameters/audit\n\nor to set it on boot add:\n\napparmor.audit=all\n\nas a kernel boot paramenter.\n"
                },
                {
                    "name": "Audit Rate Limiting",
                    "content": "If auditd is not running, to avoid losing too many of the extra log messages, you will likely\nhave to turn off rate limiting by doing:\n\necho 0 > /proc/sys/kernel/printkratelimit\n\nBut even then the kernel ring buffer may overflow and you might lose messages.\n\nElse, if auditd is running, see auditd(8) and auditd.conf(5).\n"
                }
            ]
        },
        "FILES": {
            "content": "/etc/apparmor.d/\n/var/cache/apparmor/\n/var/log/audit/audit.log\n/var/log/messages\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "apparmorparser(8),  aachangehat(2),  apparmor.d(5),  aa-autodep(1),  clean(1),  auditd(8),\naa-unconfined(8), aa-enforce(1), aa-complain(1), and <https://wiki.apparmor.net>.\n\nAppArmor 4.0.1                               2026-04-13                                  APPARMOR(7)",
            "subsections": []
        }
    },
    "summary": "AppArmor - kernel enhancement to confine programs to a limited set of resources.",
    "flags": [],
    "examples": [],
    "see_also": [
        {
            "name": "apparmorparser",
            "section": "8",
            "url": "https://www.chedong.com/phpMan.php/man/apparmorparser/8/json"
        },
        {
            "name": "aachangehat",
            "section": "2",
            "url": "https://www.chedong.com/phpMan.php/man/aachangehat/2/json"
        },
        {
            "name": "apparmor.d",
            "section": "5",
            "url": "https://www.chedong.com/phpMan.php/man/apparmor.d/5/json"
        },
        {
            "name": "aa-autodep",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/aa-autodep/1/json"
        },
        {
            "name": "clean",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/clean/1/json"
        },
        {
            "name": "auditd",
            "section": "8",
            "url": "https://www.chedong.com/phpMan.php/man/auditd/8/json"
        },
        {
            "name": "aa-unconfined",
            "section": "8",
            "url": "https://www.chedong.com/phpMan.php/man/aa-unconfined/8/json"
        },
        {
            "name": "aa-enforce",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/aa-enforce/1/json"
        },
        {
            "name": "aa-complain",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/aa-complain/1/json"
        }
    ]
}