Linux sestatus command
sestatus is a command-line tool in Linux systems used to view the current status of SELinux (Security-Enhanced Linux). SELinux is a mandatory access control (MAC) security mechanism developed by the U.S. National Security Agency (NSA), providing an additional security layer for Linux systems.
Command syntax
sestatus [选项]
Common options
| Option | Description |
|---|---|
-v |
Display detailed output, including context information of processes and files |
-b |
Display currently loaded policy booleans (rule switches) |
Command output parsing
Executing sestatus After the command, typical output is as follows:
Example
SELinux status: enabled
SELinuxfs mount:
/
sys
/
fs
/
selinux
SELinux root directory:
/
etc
/
selinux
Loaded policy name: targeted
Current mode: enforcing
Mode from config file: enforcing
Policy MLS status: enabled
Policy deny_unknown status: allowed
Memory protection checking: actual
(
secure
)
Max kernel policy version:
33
Description of key fields
-
SELinux status
enabled: SELinux is enableddisabled: SELinux is disabled-
Current mode
enforcing: Enforce the security policypermissive: Only log violations but do not blockdisabled: Completely disabled-
Loaded policy name
targeted: Default policy, only protects specific servicesmls: Multi-level security policy (stricter)minimum: Minimum policyPractical Application Examples
Example 1: Check the basic SELinux status
$ sestatus
This is the most basic usage, quickly checking whether SELinux is enabled and its operating mode.
Example 2: View detailed context information
$ sestatus -v
The output will contain context information of processes and files, for example:
Example
Process contexts:
Current context: unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
Init context: system_u:system_r:init_t:s0
...
File contexts:
Controlling terminal: unconfined_u:object_r:user_devpts_t:s0
...
Example 3: View current policy booleans
$ sestatus -b
The output will display the status of all configurable policy rule switches, for example:
Example
Policy booleans:
abrt_anon_write off
abrt_handle_event off
...
httpd_can_network_connect off
...
Troubleshooting common problems
Problem 1: SELinux blocks normal operations
Solution:
- First, confirm whether the problem is caused by SELinux:
grep "avc:" /var/log/audit/audit.log
- If so, you can temporarily set it to permissive mode for testing:
sudo setenforce 0
- The permanent solution is to adjust the SELinux policy or modify the file context
Problem 2: sestatus shows SELinux is disabled
Possible cause:
- SELinux was disabled at system startup
/etc/selinux/configSet in the fileSELINUX=disabled
Solution:
- Editing
/etc/selinux/configfile - Modify
SELINUX=enforcingorSELINUX=permissive - Reboot the system
Best Practices
-
Production environment recommendations
enforcing mode for maximum security-
Troubleshooting steps
sestatus to check the status/var/log/audit/audit.log to get detailed denial informationaudit2allow to generate a custom policy module-
Policy adjustment
setsebool to adjust booleanschcon)Summary
sestatus The command is the first tool for managing SELinux systems, through which you can quickly understand the system's security status. Mastering the use of this command can help system administrators better maintain the security of Linux systems, while quickly locating the cause when permission problems occur.
Linux Command Reference