Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Linux sestatus command

Linux sestatus command

Linux Command Reference Linux Command Reference


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

  1. SELinux status

  2. enabled: SELinux is enabled
  3. disabled: SELinux is disabled
  4. - `enabled`: SELinux is enabled - `disabled`: SELinux is disabled
    1. Current mode

    2. enforcing: Enforce the security policy
    3. permissive: Only log violations but do not block
    4. disabled: Completely disabled
    5. - `enforcing`: Enforce the security policy - `permissive`: Only log violations but do not block - `disabled`: Completely disabled
      1. Loaded policy name

      2. targeted: Default policy, only protects specific services
      3. mls: Multi-level security policy (stricter)
      4. minimum: Minimum policy
      5. - `targeted`: Default policy, only protects specific services - `mls`: Multi-level security policy (stricter) - `minimum`: Minimum policy

        Practical 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:

        1. First, confirm whether the problem is caused by SELinux:
          grep "avc:" /var/log/audit/audit.log
        2. If so, you can temporarily set it to permissive mode for testing:
          sudo setenforce 0
        3. The permanent solution is to adjust the SELinux policy or modify the file context

        Problem 2: sestatus shows SELinux is disabled

        Possible cause:

        Solution:

        1. Editing /etc/selinux/config file
        2. Modify SELINUX=enforcing or SELINUX=permissive
        3. Reboot the system

        Best Practices

        1. Production environment recommendations

        2. Keep SELinux in enforcing mode for maximum security
        3. Do not disable SELinux lightly; instead, learn how to configure it properly
        4. - Keep SELinux in `enforcing` mode for maximum security - Do not disable SELinux lightly; instead, learn how to configure it properly
          1. Troubleshooting steps

          2. First use sestatus to check the status
          3. Check /var/log/audit/audit.log to get detailed denial information
          4. Use audit2allow to generate a custom policy module
          5. - First use `sestatus` to check the status - View `/var/log/audit/audit.log` for detailed denial information - Use `audit2allow` to generate a custom policy module
            1. Policy adjustment

            2. Priority use setsebool to adjust booleans
            3. Secondly, consider modifying the file context (chcon)
            4. Finally, consider creating a custom policy module
            5. - Priority use `setsebool` to adjust booleans - Secondly, consider modifying the file context (`chcon`) - Finally, consider creating a custom policy module

              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 Linux Command Reference