OnCallReadyStart learning

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-status

loaded profiles and their modes, then the confined processes

$ sudo aa-status --show=processes --filter.profiles=k8s

only the processes under your profiles

$ sudo aa-status --enabled && echo on

is AppArmor on? (exit status only)

$ sudo aa-status --json | jq -r '.profiles | keys[]'

the profile names, for a script

Gotchas

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.