Linux "chcon" Command Line Options and Examples
change file security context

Change the SELinux security context of each FILE to CONTEXT. With --reference, change the security context of each FILE to that of RFILE. Mandatory arguments to long options are mandatory for short options too.


Usage:

chcon [OPTION]... CONTEXT FILE...
    chcon [OPTION]... [-u USER] [-r ROLE] [-l RANGE] [-t TYPE] FILE...
    chcon [OPTION]... --reference=RFILE FILE...




Command Line Options:

--dereference
affect the referent of each symbolic link (this is the default), rather than the symbolic link itself
chcon --dereference ...
-h
affect symbolic links instead of any referenced file
chcon -h ...
-u
set user USER in the target security context
chcon -u ...
-r
set role ROLE in the target security context
chcon -r ...
-t
set type TYPE in the target security context
chcon -t ...
-l
set range RANGE in the target security context
chcon -l ...
--no-preserve-root
do not treat '/' specially (the default)
chcon --no-preserve-root ...
--preserve-root
fail to operate recursively on '/'
chcon --preserve-root ...
--reference
use RFILE's security context rather than specifying a CONTEXT value
chcon --reference ...
-R
operate on files and directories recursively
chcon -R ...
-v
output a diagnostic for every file processedThe following options modify how a hierarchy is traversed when the -R option is also specified. If more than one is specified, onlythe final one takes effect.
chcon -v ...
-H
if a command line argument is a symbolic link to a directory, traverse it
chcon -H ...
-L
traverse every symbolic link to a directory encountered
chcon -L ...
-P
do not traverse any symbolic links (default)
chcon -P ...
--help
display this help and exit
chcon --help ...
--version
output version information and exitAUTHORWritten by Russell Coker and Jim Meyering.REPORTING BUGSGNU coreutils online help: <http://www.gnu.org/software/coreutils/>Report chcon translation bugs to <http://translationproject.org/team/>COPYRIGHTCopyright © 2017 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
chcon --version ...