APPARMOR_PARSER(8)
โจ NAME โจ
Ok bestie, meet APPARMOR_PARSER(8) โ it's apparmor_parser, and it loads AppArmor profiles into the kernel. That's the whole name-card vibe. ๐
๐ฆ SYNOPSIS ๐ฆ
apparmor_parser [options] <command> [profiles]...
apparmor_parser [options] <command>
apparmor_parser [-hv] [--help] [--version]
๐ธ DESCRIPTION ๐ธ
So apparmor_parser is your general tool for compiling and managing AppArmor policy. That includes loading new apparmor.d(5) profiles into the Linux kernel. Periodt. ๐
AppArmor profiles restrict the operations available to processes. Main character energy for security, honestly. ๐ซถ
The profiles get loaded into the Linux kernel by the apparmor_parser program. You can point it at a file name or a directory name containing a set of profiles. If you give it a directory, apparmor_parser will try to do a profile load for each file in that directory that is not a dot file, or explicitly black listed: *.dpkg-new, *.dpkg-old, *.dpkg-dist, *.dpkg-bak, *.dpkg-remove, *.pacsave, *.pacnew, *.rpmnew, *.rpmsave, *.orig, *.rej, *~. If you don't supply a profile or directory, it will fall back to taking input from standard input. No cap. โจ
The input you feed to apparmor_parser should be in the format described in apparmor.d(5). That's the whole assignment. ๐
๐ COMMANDS ๐
The command set is broken into four subcategories.
unprivileged commands
- Commands that don't require any privilege and don't operate on profiles.
unprivileged profile commands
- Commands that operate on a profile either specified on the command line or read from stdin if no profile was specified.
privileged commands
- Commands that require the
MAC_ADMINcapability within the affected AppArmor namespace to load policy into the kernel or filesystem write permissions to update the affected privileged files (cache etc).
privileged profile commands
- Commands that require privilege and operate on profiles.
โจ Unprivileged commands โจ
-V,--versionโ Print the version number and exit. Slay, short and sweet. ๐-h,--helpโ Give a quick reference guide. Your lil map, bestie.
๐ Unprivileged profile commands ๐
-N,--namesโ Produce a list of policies from a given set of profiles (implies-K).-p,--preprocessโ Apply preprocessing to the input profile(s) by flattening includes into the output profile and dump to stdout.-S,--stdoutโ Writes a binary (cached) profile to stdout (implies-Kand-T).-o file,--ofile fileโ Writes a binary (cached) profile to the specified file (implies-Kand-T)
๐ฅ Privileged commands ๐ฅ
--purge-cacheโ Unconditionally clear out cached profiles. Bye, cache. ๐
๐ Privileged profile commands ๐
-a,--addโ Insert the AppArmor definitions given into the kernel. This is the default action. This gives an error message if an AppArmor definition by the same name already exists in the kernel, or if the parser doesn't understand its input. It reports when an addition succeeded.-r,--replaceโ This flag is required if an AppArmor definition by the same name already exists in the kernel; used to replace the definition already in the kernel with the definition given on standard input.-R,--removeโ This flag is used to remove an AppArmor definition already in the kernel. Note that it still requires a complete AppArmor definition as described inapparmor.d(5)even though the contents of the definition aren't used.
โจ OPTIONS โจ
Ok now the big one, bestie. Every flag, every default, no skips. ๐
-B,--binaryโ Treat the profile files specified on the command line (or stdin if none specified) as binary cache files, produced with the-Sor-ooptions, and load to the kernel as specified by-a,-r, and-R(implies-Kand-T).-C,--Complainโ Force the profile to load in complain mode.-b n,--base nโ Set the base directory for resolving#includedirectives defined as relative paths.-I n,--Include nโ Add elementnto the search path when resolving#includedirectives defined as an absolute paths.-f n,--apparmorfs nโ Set the location of the apparmor security filesystem (default is"/sys/kernel/security/apparmor").--policy-features nโ Specify the feature set that the policy was developed under. This does not override feature ABI rules.--override-policy-abi nโ Specify the feature set that the policy was developed under and override any feature ABI rules that the policy may be using.--kernel-features nโ Specify the feature set of the kernel that the policy is being compiled for. If not specified this will be determined by the system's kernel.-M n,--features-file nโ Use the features file located at path"n"(default is/etc/apparmor.d/cache/.features). If the--cache-locoption is present, the".features"file in the specified cache directory is used.
Note: this sets both the --kernel-features and --policy-features to be the same.
-m n,--match-string nโ Only use match features"n".
Note: this sets both the --kernel-features and --policy-features to be the same.
-n n,--namespace-string nโ Force a profile to load in the namespace"n".-X,--readimpliesXโ In the case of profiles that are loading on systems wereREAD_IMPLIES_EXECis set in the kernel for a given process, load the profile so that any"r"flags are processed as"mr".-k,--show-cacheโ Report the cache processing (hit/miss details) when loading or saving cached profiles.-K,--skip-cacheโ Perform no caching at all: disables-W, implies-T.-T,--skip-read-cacheโ By default, if a profile's cache is found in the location specified by--cache-locand the timestamp is newer than the profile, it will be loaded from the cache. This option disables this cache loading behavior.-W,--write-cacheโ Write out cached profiles to the location specified in--cache-loc. Off by default. In cases where abstractions have been changed, and the parser is running with"--replace", it may make sense to also use"--skip-read-cache"with the"--write-cache"option.--skip-bad-cacheโ Skip updating the cache if it contains cached profiles in a bad or inconsistent state-L,--cache-locโ Set the location(s) of the cache directory. This option can accept a comma separated list of directories, which will be searched in order to find a matching cache. The first matching cache file found is used even if a directory later in the search order may contain a newer cache file.
If multiple directories are specified and --write-cache has been specified then cache writes will be made to the first directory in the list, all other directories will be treated as read only.
If a cache directory name needs to have a comma as part of the name, it can be specified by using a backslash to escape the comma character in the directory name.
If not specified the cache location defaults to /var/cache/apparmor
--print-cache-dirโ Print the cache directory location. This path will be a subdirectory of the directory specified by--cache-loc. The subdirectory used will be influenced by the features available in the currently running kernel or by the features specified with the--match-stringor--features-fileoptions.-Q,--skip-kernel-loadโ Perform all actions except the actual loading of a profile into the kernel. This is useful for testing profile generation, caching, etc, without making changes to the running kernel profiles.
This also removes the need for privilege to execute the commands that manage policy in the kernel
-q,--quietโ Do not report on the profiles as they are loaded, and not show warnings.-v,--verboseโ Report on the profiles as they are loaded, and show warnings.--warn=nโ Enable various warnings during policy compilation. A single warn flag can be specified per--warnoption, but the--warnflag can be passed multiple times.
apparmor_parser --warn=rule-not-enforced ...
A specific warning can be disabled by prepending no- to the flag
apparmor_parser --warn=no-rule-not-enforced ...
Use --help=warn to see a full list of which warn flags are supported.
--Werror[=n]โ Convert warnings into errors during policy compilation. If the optional flag is not specified all warnings become errors. If the optional flag is specified only the class of warnings specified will become errors. A single flag can be specified per--Werroroption, but the--Werrorflag can be passed multiple times.
apparmor_parser --Werror=deprecated ...
Use --help=warn or --help=Werror to see a full list of which warn flags are supported.
-d,--debugโ Given once, only checks the profiles to ensure syntactic correctness. Given twice, dumps its interpretation of the profile for checking.-D n,--dump=nโ Debug flag for dumping various structures and passes of policy compilation. A single dump flag can be specified per--dumpoption, but the dump flag can be passed multiple times. Note progress flags tend to also imply the matching stats flag.
apparmor_parser --dump=dfa-stats --dump=trans-stats <file>
Use --help=dump to see a full list of which dump flags are supported
-j n,--jobs=nโ Set the number of jobs used to compile the specified policy. Wherencan be0โ disable jobs and use the main process for all compilation#โ a specific number of jobsautoโ the # of cpus in the in the systemx#โ # * number of cpus
Eg.
-j8 OR --jobs=8 allows for 8 parallel jobs
-jauto OR --jobs=auto sets the jobs to the # of
cpus
-jx4 OR --jobs=x4 sets the jobs to # of cpus *
4
-jx1 is equivalent to -jauto
The default value is the number of cpus in the system. Note that if jobs is a positive integer number the --jobs-max parameter is automatically set to the same value.
-c[n],--zstd-compress-level=nโ Compress the profile using the zstd algorithm at leveln.noneโ turns compression all the way off, same thing as saying0โจdefaultโ the default apparmor preset compression level, it just does its thing ๐fastโ a pre-chosen value that is fast ๐โโ๏ธ๐จsmallโ a pre-chosen value that gets you better compression (but slower, sorry bestie ๐ญ)0-22โ a number in the range0-22, where a compression level of0disables compression entirely. Levels otherwise range up to22, though levels of20and above (the 'ultra' levels ๐) require significantly more memory and are much slower.
Policies can be loaded and stored in the kernel in compressed format, which is lowkey iconic. Using a higher level of compression, policy can save both CPU time and memory, especially when compressed policies are retrieved from an existing cache. Efficiency queen fr fr ๐
If the compression level is unspecified, a default value of 10 is used. Heads up tho: --zstd-compress-level values only affect container compression, unlike the --Optimize flag which adjusts multiple optimization parameters. Different vibes, different jobs ๐ซ
See also the optimization flag zstd-recompress โ it's giving related content.
--max-jobs nโ when--jobsis set to a scaling value (ie.autoorxN), this sets a hard cap on the value that can be specified by the--jobsflag. It takes the same set of options available to the--jobsoption, and defaults to8*cpus๐-O n,--optimize=nโ sets the optimization flags used by policy compilation. A single optimization flag can be toggled per-Ooption, but the optimize flag can be passed multiple times. Turning off some phases of the optimization can make it so that policy can't complete compilation due to size constraints (it is entirely possible to create a dfa with millions of states that will take days or longer to compile ๐ญ absolutely not the move).
Note: The parser is set to use a balanced default set of flags, that will result in reasonable compression but not take excessive amounts of time to complete. She's balanced, she's mindful, she's thriving ๐
Use --help=optimize to see a full list of which optimization flags are supported.
zstd-recompressโ force recompression of the policy file if the compression level is higher than the currently cached file. Glow-up for your cache โจ
--abort-on-errorโ abort processing of profiles on the first error encountered, otherwise the parser will continue to try to compile other profiles if specified.
Note: If an error is encountered while processing profiles the last error encountered will be used to set the exit code. Noted, logged, remembered ๐
--skip-bad-cache-rebuildโ the default behavior of the parser is to check if a cached version of a profile exists and if it does it attempt to load it into the kernel. If that load is rejected, then the parser will attempt to rebuild the cache file, and load again. This option tells the parser to not attempt to rebuild the cache on failure, instead the parser continues on with processing the remaining profiles. Keep it moving, no looking back ๐--estimated-compile-sizeโ adjust the internal parameter used to estimate how aggressive the parser can be when compiling policy. This may include changes to how or when caches are dropped or how many compile units (jobs) are launched. The value should slightly larger than the largest Resident Set Size (RSS) encountered for the type of policy being compiled.
A value that is too small may result in the parser exhausting system resources when compiling large policy. A value too large may slow policy compiles down. So likeโฆ pick wisely bestie ๐ญ
The value specified may include a suffix of KB, MB, GB, to make it easier to adjust the size.
Note: config-file and command line options will override values chosen by tuning affected by the option.
--config-fileโ specify the config file to use instead of/etc/apparmor/parser.conf. This option will be processed early before regular options regardless of the order it is specified in. She goes first, always ๐--print-config-fileโ print the config file location that will be used. Show me the receipts ๐งพ
๐ธ CONFIG FILE ๐ธ
An optional config file /etc/apparmor/parser.conf can be used to specify the default options for the parser, which then can be overridden using the command line options. Command line stays the main character ๐
The config file ignores leading whitespace and treats lines that begin with # as comments. Config options are specified one per line using the same format as the longform command line options (without the preceding --).
Eg.
#comment
optimize=no-expr-tree
optimize=compress-fast
As with the command line some options accumulate and others override, ie. when there are conflicting versions of switch the last option is the one chosen. Last one wins, that's just the rules bestie โจ
Eg.
Optimize=no-minimize
Optimize=minimize
would result in Optimize=minimize being set.
The Include, Dump, and Optimize options accumulate except for the inversion option (no-X vs. X), and a couple options that work by setting/clearing multiple options (compress-small). In that case the option will override the flags it sets but will may accumulate with others. It's giving complicated but we move ๐ฆ
All other options override previously set values.
๐ BUGS ๐
If you find any bugs, please report them at <https://gitlab.com/apparmor/apparmor/-/issues>. Do not gatekeep the bugs, that's not the vibe ๐
๐ SEE ALSO ๐
apparmor(7), apparmor.d(5), aa_change_hat(2), and <https://wiki.apparmor.net>. Go read those too, iykyk ๐ซถ
And that's the whole page, bestie!! ๐ This was from AppArmor 6.0.0~alpha1, dated 2026-10-05, and it's APPARMOR_PARSER(8) โ iconic, legendary, no notes. Now go compress some policy and slay ๐โจ๐
๐ฆ where this page comes from
- ubuntu stonking: apparmor 6.0.0~alpha1-0ubuntu4 ยท GPL-2.0-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms