chcon
chcon [OPCIÓN]... CONTEXTO ARCHIVO...
chcon [OPCIÓN]... [-u USUARIO] [-r ROL] [-l RANGO] [-t TIPO] ARCHIVO...
chcon [OPCIÓN]... --reference=RARCHIVO ARCHIVO...
Cambiar el contexto de seguridad SELinux de cada ARCHIVO a CONTEXTO. Con –reference, cambiar el contexto de seguridad de cada ARCHIVO al de RARCHIVO.
Options
--dereference-
Afectar el referente de cada enlace simbólico (esto es por defecto), en lugar del enlace simbólico mismo.
--no-dereference,-h-
Afectar enlaces simbólicos en lugar de cualquier archivo referenciado.
--help-
help
--preserve-root-
Fallar al operar recursivamente en ‘/’.
--no-preserve-root-
No tratar ‘/’ especialmente (por defecto).
--reference=<RFILE>-
Usar contexto de seguridad de RARCHIVO, en lugar de especificar un valor CONTEXTO.
--user=<USER>,-u <USER>-
Establecer usuario USUARIO en el contexto de seguridad destino.
--role=<ROLE>,-r <ROLE>-
Establecer rol ROL en el contexto de seguridad destino.
--type=<TYPE>,-t <TYPE>-
Establecer tipo TIPO en el contexto de seguridad destino.
--range=<RANGE>,-l <RANGE>-
Establecer rango RANGO en el contexto de seguridad destino.
--recursive,-R-
Operar en archivos y directorios recursivamente.
-H-
Si un argumento de línea de comandos es un enlace simbólico a un directorio, atravesarlo. Solo válido cuando se especifica -R.
-L-
Atravesar cada enlace simbólico a un directorio encontrado. Solo válido cuando se especifica -R.
-P-
No atravesar ningún enlace simbólico (por defecto). Solo válido cuando se especifica -R.
--verbose,-v-
Mostrar un diagnóstico para cada archivo procesado.
Examples
View security context of a file:
ls {{[-lZ|-l --context]}} {{path/to/file}}
Change the security context of a target file, using a reference file:
chcon --reference {{reference_file}} {{target_file}}
Change the full SELinux security context of a file:
chcon {{user}}:{{role}}:{{type}}:{{range/level}} {{filename}}
Change only the user part of SELinux security context:
chcon {{[-u|--user]}} {{user}} {{filename}}
Change only the role part of SELinux security context:
chcon {{[-r|--role]}} {{role}} {{filename}}
Change only the type part of SELinux security context:
chcon {{[-t|--type]}} {{type}} {{filename}}
Change only the range/level part of SELinux security context:
chcon {{[-l|--range]}} {{range/level}} {{filename}}
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.