secon

Display SELinux security contexts

TLDR

Get current execution context
$ secon
Get context of a process
$ secon --pid 1
Get context of a file
$ secon --file path/to/file
Get context of a symlink (don't resolve)
$ secon --link path/to/symlink
Parse a context specification
$ secon system_u:system_r:container_t:s0

SYNOPSIS

secon [options] [context]

DESCRIPTION

secon retrieves and displays SELinux security contexts. It can show the context of the current execution, processes, files, or parse context specifications.Output includes user, role, type, and level components of the SELinux context.

PARAMETERS

--pid pid

Get context of specified process
--file path
Get context of file (follows symlinks)
--link path
Get context of symlink (don't follow)

INSTALL

sudo apt install policycoreutils
sudo dnf install policycoreutils
sudo zypper install policycoreutils
nix profile install nixpkgs#policycoreutils

CAVEATS

Requires SELinux to be enabled. File context may differ from actual access context.

HISTORY

Part of libselinux-utils, providing SELinux context inspection tools.

SEE ALSO

runcon(1), chcon(1), semanage(8)