tldr/pages/common/chcon.md
Andrik Albuquerque f293d52ca5 chcon: add page (#2895)
<!-- Thank you for sending a PR! -->
<!-- Please perform the following checks and mark all the boxes accordingly. -->
<!-- You can remove the checklist items that don't apply to your PR. -->

- [x] The page (if new), does not already exist in the repo.
- [x] The page is in the correct platform directory (`common/`, `linux/`, etc.)
- [x] The page has 8 or fewer examples.
- [x] The PR title conforms to the recommended [templates](/tldr-pages/tldr/blob/master/CONTRIBUTING.md#commit-message).
- [x] The page follows the [content guidelines](/tldr-pages/tldr/blob/master/CONTRIBUTING.md#guidelines).
2019-04-11 17:51:59 -03:00

769 B

chcon

Change SELinux security context of a file or files/directories.

  • View security context of a file:

ls -lZ {{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}} {{filename}}

  • Change only the role part of SELinux security context:

chcon -r {{role}} {{filename}}

  • Change only the type part of SELinux security context:

chcon -t {{type}} {{filename}}

  • Change only the range/level part of SELinux security context:

chcon -l {{range/level}} {{filename}}