50.2.12. Useful Commands for Scripts
The following is a list of useful commands introduced with SELinux, and which you may find useful when writing scripts to help administer your system:
getenforce- This command returns the enforcing status of SELinux.
setenforce [ Enforcing | Permissive | 1 | 0 ]- This command controls the enforcing mode of SELinux. The option
1orEnforcingtells SELinux to enter enforcing mode. The option0orPermissivetells SELinux to enter passive mode. Access violations are still logged, but not prevented. selinuxenabled- This command exits with a status of
0if SELinux is enabled, and1if SELinux is disabled.selinuxenabled echo $?
~]# selinuxenabled ~]# echo $? 0Copy to Clipboard Copied! Toggle word wrap Toggle overflow getsebool [-a] [boolean_name]- This command shows the status of all booleans (
-a) or a specific boolean (<boolean_name>). setsebool [-P] <boolean_name> value | bool1=val1 bool2=val2 ...- This command sets one or more boolean values. The
-Poption makes the changes persistent across reboots. togglesebool boolean ...- This command toggles the setting of one or more booleans. This effects boolean settings in memory only; changes are not persistent across reboots.