aa-status: display various information about the current AppArmor policy
aa-status [option]
What it does
Reports the state of AppArmor confinement. By default it displays the same information as --verbose: whether the module is loaded, how many profiles are loaded and in which mode (enforce, complain, ...) with their names, and which processes run under a profile. Reading the policy needs root.
Options you will use
--enabled- Returns error code if AppArmor is not enabled (prints nothing).
--profiled- Displays the number of loaded AppArmor policies.
--enforced- Displays the number of loaded enforcing AppArmor policies.
--complaining- Displays the number of loaded non-enforcing AppArmor policies.
--verbose- Displays multiple data points about loaded AppArmor policy set (the default action if no arguments are given).
--json- Displays multiple data points about loaded AppArmor policy set in a JSON format, fit for machine consumption.
--pretty-json- Same as --json, formatted to be readable by humans as well as by machines.
--show WHAT- What data sets to show information about: processes, profiles, or all (the default).
--count- Display only counts for selected information.
--filter.profiles REGEX- A POSIX regular expression applied to the profile names, reducing the output.
--filter.mode REGEX- Only the profiles / processes whose mode matches (enforce, complain, prompt, kill, unconfined, mixed).
--filter.pid REGEX- Only the processes whose PID matches.
--filter.exe REGEX- Only the processes whose executable matches.
--special-unconfined- Displays the number of loaded profiles in unconfined mode.
--process-mixed- Displays the number of processes confined by a stack of profiles in different modes.
--quiet- Do not output error messages.
--help- Displays a short usage statement (--help=legacy, --help=filters for more).
Examples
$ sudo aa-statusloaded profiles and their modes, then the confined processes
$ sudo aa-status --show=processes --filter.profiles=k8sonly the processes under your profiles
$ sudo aa-status --enabled && echo onis AppArmor on? (exit status only)
$ sudo aa-status --json | jq -r '.profiles | keys[]'the profile names, for a script
Gotchas
- Exit status: 0 = AppArmor enabled and policy loaded; 1 = not enabled; 2 = enabled but no policy loaded; 3 = the control files under /sys/kernel/security/ are not available; 4 = not enough privileges to read them (run it with sudo); 42 = internal error.
- Accepts only one option at a time.
- The processes part: one line per confined process,
EXECUTABLE (PID) PROFILE, sorted by profile; the profile is left out when it is named like the executable. A container runs under containerd's cri-containerd.apparmor.d unless its pod asks for Localhost / Unconfined or it is privileged; the pause sandboxes are not confined. - The executable is realpath() of /proc/PID/exe on the host: a container path that also exists on the node resolves to the node's file (busybox /bin/sleep reads /usr/bin/sleep on Ubuntu).
Try aa-status in a real terminal Free, in your browser - a real Ubuntu terminal to try it in, with missions that check your work.