From f182e39a00873c306888b0b6e98e89d3141f5d66 Mon Sep 17 00:00:00 2001 From: Pranav Lawate Date: Wed, 8 Oct 2025 10:32:10 +0530 Subject: [PATCH] setfiles: add page (#18473) Co-authored-by: Managor <42655600+Managor@users.noreply.github.com> --- pages/linux/setfiles.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 pages/linux/setfiles.md diff --git a/pages/linux/setfiles.md b/pages/linux/setfiles.md new file mode 100644 index 0000000000..dfaec34402 --- /dev/null +++ b/pages/linux/setfiles.md @@ -0,0 +1,26 @@ +# setfiles + +> Set SELinux file security contexts based on policy rules. +> Similar to `restorecon` but reads contexts from a file_contexts file. +> See also: `restorecon`, `semanage-fcontext`, `fixfiles`. +> More information: . + +- Set file contexts according to the default policy file: + +`sudo setfiles /etc/selinux/targeted/contexts/files/file_contexts {{path/to/directory}}` + +- Set file contexts recursively and show changes: + +`sudo setfiles /etc/selinux/targeted/contexts/files/file_contexts {{path/to/directory}} {{[-v|--verbose]}}` + +- Preview what would be changed without actually modifying contexts: + +`sudo setfiles /etc/selinux/targeted/contexts/files/file_contexts {{path/to/directory}} {{[-n|--nochange]}}` + +- Set file contexts and verify them: + +`sudo setfiles /etc/selinux/targeted/contexts/files/file_contexts {{path/to/directory}} {{[-v|--verbose]}} {{[-F|--force]}}` + +- Use a specific root path for context matching: + +`sudo setfiles /etc/selinux/targeted/contexts/files/file_contexts {{path/to/new_directory}} {{[-r|--rootpath]}} {{path/to/old_directory}}`