---
name: "sefcontext_compile"
section: "8"
platform: "linux"
package: "selinux-utils"
version: "3.8.1-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/sefcontext_compile"
---

# sefcontext\_compile(8)

compile file context regular expression files

## NAME

sefcontext\_compile - compile file context regular expression files

## SYNOPSIS

**sefcontext\_compile** \[**-o** *outputfile*\] \[**-p** *policyfile*\] *inputfile*

## DESCRIPTION

**sefcontext\_compile** is used to compile file context regular expressions into [**pcre**(3)](/pcre/3.md) format.

The compiled file is used by libselinux file labeling functions.

By default **sefcontext\_compile** writes the compiled pcre file with the **.bin** suffix appended (e.g. *inputfile***.bin**).

## OPTIONS

- **-o**

  Specify an *outputfile* that must be a fully qualified file name as the **.bin** suffix is not automatically added.

- **-p**

  Specify a binary *policyfile* that will be used to validate the context entries in the *inputfile*\
   If an invalid context is found the pcre formatted file will not be written and an error will be returned.

## RETURN VALUE

On error -1 is returned.  On success 0 is returned.

## EXAMPLES

**Example 1:**\
 sefcontext\_compile /etc/selinux/default/contexts/files/file\_contexts

Results in the following file being generated:

/etc/selinux/default/contexts/files/file\_contexts.bin

**Example 2:**\
 sefcontext\_compile -o new\_fc.bin /etc/selinux/default/contexts/files/file\_contexts

Results in the following file being generated in the cwd:

new\_fc.bin

## AUTHOR

Dan Walsh, \<dwalsh@redhat.com\>

## SEE ALSO

[**selinux**(8)](/selinux/8.md), [**semanage**(8)](/semanage/8.md),
