From 209a3205b7e7c1c8ab505f10231783b55d9673bf Mon Sep 17 00:00:00 2001 From: Pranav Lawate Date: Sun, 5 Oct 2025 21:01:31 +0530 Subject: [PATCH 1/3] setfiles: add page --- 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 00000000000000..d9dc18a70aaed8 --- /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 {{[-v|--verbose]}} /etc/selinux/targeted/contexts/files/file_contexts {{path/to/directory}}` + +- Preview what would be changed without actually modifying contexts: + +`sudo setfiles {{[-n|--nochange]}} /etc/selinux/targeted/contexts/files/file_contexts {{path/to/directory}}` + +- Set file contexts and verify them: + +`sudo setfiles {{[-v|--verbose]}} {{[-F|--force]}} /etc/selinux/targeted/contexts/files/file_contexts {{path/to/directory}}` + +- Use a specific root path for context matching: + +`sudo setfiles {{[-r|--rootpath]}} {{/old/path}} /etc/selinux/targeted/contexts/files/file_contexts {{/new/path}}` From 2655f441573a212d428e1db9796cc09e97df741b Mon Sep 17 00:00:00 2001 From: Pranav Lawate Date: Sun, 5 Oct 2025 23:18:57 +0530 Subject: [PATCH 2/3] Update pages/linux/setfiles.md Co-authored-by: Managor <42655600+Managor@users.noreply.github.com> --- pages/linux/setfiles.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/linux/setfiles.md b/pages/linux/setfiles.md index d9dc18a70aaed8..ba6361a2c3034d 100644 --- a/pages/linux/setfiles.md +++ b/pages/linux/setfiles.md @@ -23,4 +23,4 @@ - Use a specific root path for context matching: -`sudo setfiles {{[-r|--rootpath]}} {{/old/path}} /etc/selinux/targeted/contexts/files/file_contexts {{/new/path}}` +`sudo setfiles {{[-r|--rootpath]}} {{path/to/old_directory}} /etc/selinux/targeted/contexts/files/file_contexts {{path/to/new_directory}}` From 27871ea68b36876bf3a595240a523e081fc6c31b Mon Sep 17 00:00:00 2001 From: Pranav Lawate Date: Tue, 7 Oct 2025 19:24:58 +0530 Subject: [PATCH 3/3] setfiles: reorder positional args before options --- pages/linux/setfiles.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pages/linux/setfiles.md b/pages/linux/setfiles.md index ba6361a2c3034d..dfaec344025f4c 100644 --- a/pages/linux/setfiles.md +++ b/pages/linux/setfiles.md @@ -11,16 +11,16 @@ - Set file contexts recursively and show changes: -`sudo setfiles {{[-v|--verbose]}} /etc/selinux/targeted/contexts/files/file_contexts {{path/to/directory}}` +`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 {{[-n|--nochange]}} /etc/selinux/targeted/contexts/files/file_contexts {{path/to/directory}}` +`sudo setfiles /etc/selinux/targeted/contexts/files/file_contexts {{path/to/directory}} {{[-n|--nochange]}}` - Set file contexts and verify them: -`sudo setfiles {{[-v|--verbose]}} {{[-F|--force]}} /etc/selinux/targeted/contexts/files/file_contexts {{path/to/directory}}` +`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 {{[-r|--rootpath]}} {{path/to/old_directory}} /etc/selinux/targeted/contexts/files/file_contexts {{path/to/new_directory}}` +`sudo setfiles /etc/selinux/targeted/contexts/files/file_contexts {{path/to/new_directory}} {{[-r|--rootpath]}} {{path/to/old_directory}}`