snippetbashTip
selinuxenabled — Check whether SELinux is enabled. Returns exit code 0 if SELinux is enabled, and 1 if it is not. See
Viewed 0 times
commandselinuxwhetherreturnsclicheckenabledselinuxenabled
linux
Problem
How to use the
selinuxenabled command: Check whether SELinux is enabled. Returns exit code 0 if SELinux is enabled, and 1 if it is not. See also: getenforce, setenforce, sestatus. More information: <https://manned.org/selinuxenabled>.Solution
selinuxenabled — Check whether SELinux is enabled. Returns exit code 0 if SELinux is enabled, and 1 if it is not. See also: getenforce, setenforce, sestatus. More information: <https://manned.org/selinuxenabled>.Check if SELinux is enabled (no output; check exit code with
echo $?):selinuxenabledCheck if SELinux is enabled and print the result:
selinuxenabled && echo "SELinux is enabled" || echo "SELinux is disabled"Use in a shell script to conditionally execute commands:
if selinuxenabled; then echo "SELinux is running"; fiCode Snippets
Check if SELinux is enabled (no output; check exit code with `echo $?`)
selinuxenabledCheck if SELinux is enabled and print the result
selinuxenabled && echo "SELinux is enabled" || echo "SELinux is disabled"Use in a shell script to conditionally execute commands
if selinuxenabled; then echo "SELinux is running"; fiContext
tldr-pages: linux/selinuxenabled
Revisions (0)
No revisions yet.