CHCON(1) General Commands Manual CHCON(1)

chconalter SELinux context of files and directory trees

chcon [-v] [-h|--dereference]|[-R [-P|-H|-L] [-x] [--[no-]preserve-root]] context file
chcon [-v] [-h|--dereference]|[-R [-P|-H|-L] [-x] [--[no-]preserve-root]] [-u user] [-r role] [-t type] [-l range] file… (with at least one of -urtl)
chcon [-v] [-h|--dereference]|[-R [-P|-H|-L] [-x] [--[no-]preserve-root]] --reference=ref-file file

Labels files (and, with -R, their children) with the specified context:

with context
context,
with at least one of -urtl
the file's current label with the specified fields altered,
with --reference
the label of ref-file (symbolic link always followed).

If a file is already labelled with the target context, it is not re-set.

, --verbose
Note each file processed to the standard output stream.

, --no-dereference
Label symbolic links themselves, not their targets.
Follow symbolic links when labelling. This is the default, unless -R.

, --recursive
Also change context of all of files' descendants, depth-first.
and don't follow any symbolic links during the descent. This is the default.
and only follow files, but not any of their descendants.
and follow all symbolic links.

, --one-file-system
Don't label or descend to filesystems (mount-points) different than their corresponding file.
With -R, refuse to process /.
Don't. This is the default.

, --user=user
Change user (the first field) to user.
, --role=role
Change role (the second field) to role.
, --type=type
Change type (the third field) to type.
, --range=range
Change level-range (the fourth field) to range.

if a file was unlabelled in -urtl mode, ref-file was unlabelled (or didn't exist), a file couldn't be labelled, a directory couldn't be read with -R, or -R --preserve-root and / was encountered.

chcon(1), getfscon(3), setfscon(3), selinux(8)

Compatible with the GNU system. -x is an extension.

July 27, 2022 voreutils pre-v0.0.0-latest