mirror of
https://github.com/tldr-pages/tldr.git
synced 2025-04-23 03:22:08 +02:00

<!-- 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).
31 lines
769 B
Markdown
31 lines
769 B
Markdown
# 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}}`
|