APPARMOR_PARSER(8) AppArmor APPARMOR_PARSER(8)
apparmor_parser — loads AppArmor profiles into the kernel
| Use Case | Command | Description |
|---|---|---|
| Load a profile | apparmor_parser --add profile |
Insert a new AppArmor profile into the kernel |
| Replace an existing profile | apparmor_parser --replace profile |
Replace an existing profile definition |
| Remove a profile | apparmor_parser --remove profile |
Remove a profile from the kernel |
| Load all profiles from a directory | apparmor_parser --add /etc/apparmor.d |
Load all profiles from the standard directory |
| Compile profile to stdout (binary cache) | apparmor_parser --stdout profile |
Write binary cache to stdout, useful for inspection |
| Force complain mode | apparmor_parser --Complain profile |
Load profile in complain (audit-only) mode |
| Check syntax only | apparmor_parser --debug profile |
Check for syntax errors without loading |
| Show version | apparmor_parser --version |
Print version and exit |
| Help | apparmor_parser --help |
Show quick reference guide |
| Purge cache | apparmor_parser --purge-cache |
Clear all cached profiles |
apparmor_parser [options] <command> [profiles]...
apparmor_parser [options] <command>
apparmor_parser [-hv] [--help] [--version]
apparmor_parser is used as a general tool to compile, and manage AppArmor policy, including loading new apparmor.d(5) profiles into the Linux kernel.
AppArmor profiles restrict the operations available to processes.
The profiles are loaded into the Linux kernel by the apparmor_parser program. The profiles may be specified by file name or a directory name containing a set of profiles. If a directory is specified then the apparmor_parser will try to do a profile load for each file in the 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, *~). The apparmor_parser will fall back to taking input from standard input if a profile or directory is not supplied.
The input supplied to apparmor_parser should be in the format described in apparmor.d(5).
The command set is broken into four subcategories.
-V, --version — Print the version number and exit.-h, --help — Give a quick reference guide.-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 -K and -T).-o file, --ofile file — Writes a binary (cached) profile to the specified file (implies -K and -T).--purge-cache — Unconditionally clear out cached profiles.-a, --add — Insert the AppArmor definitions given into the kernel. This is the default action. This gives an error message if a 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 in apparmor.d(5) even though the contents of the definition aren't used.-B, --binary — Treat the profile files specified on the command line (or stdin if none specified) as binary cache files, produced with the -S or -o options, and load to the kernel as specified by -a, -r, and -R (implies -K and -T).-C, --Complain — Force the profile to load in complain mode.-b n, --base n — Set the base directory for resolving #include directives defined as relative paths.-I n, --Include n — Add element n to the search path when resolving #include directives defined as 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-loc option is present, the ".features" file in the specified cache directory is used.-m n, --match-string n — Only use match features "n".-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 were READ_IMPLIES_EXEC is 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-loc and 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-string or --features-file options.-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 --warn option, but the --warn flag can be passed multiple times. Example: apparmor_parser --warn=rules-not-enforced ... A specific warning can be disabled by prepending no- to the flag: apparmor_parser --warn=no-rules-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. Example: 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. Example: 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. Where n can be: 0 (disable jobs), # (specific number), auto (number of CPUs), x# (multiplier). Example: -j8 OR --jobs=8 -jauto OR --jobs=auto -jx4 OR --jobs=x4 Default is number of CPUs.--max-jobs n — When --jobs is set to a scaling value (auto or xN), set a hard cap. Defaults to 8*cpus.-O n, --optimize=n — Set optimization flags. Can be passed multiple times. Use --help=optimize for full list.--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.--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.--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.--print-config-file — Print the config file location that will be used.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.
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 --).
Example:
#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.
Example:
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 may accumulate with others. All other options override previously set values.
If you find any bugs, please report them at https://gitlab.com/apparmor/apparmor/-/issues.
apparmor(7), apparmor.d(5), aa_change_hat(2), and https://wiki.apparmor.net.
AppArmor 3.0.4 2025-08-15 APPARMOR_PARSER(8)
Generated by phpman v4.9.26-1-g511901d Author: Che Dong Under GNU General Public License
2026-08-09 10:19 @2600:1f28:365:80b0:50b3:453e:ff52:20f7
CrawledBy CCBot/2.0 (https://commoncrawl.org/faq/)
Enhanced by LLM: deepseek-v4-flash / taotoken.net / www.chedong.com - original format