zoukankan      html  css  js  c++  java
  • Linux服务器关闭SeLinux的方法

    [danny@localhost ~]$ cat /etc/selinux/config

    # This file controls the state of SELinux on the system.
    # SELINUX= can take one of these three values:
    #     enforcing - SELinux security policy is enforced.
    #     permissive - SELinux prints warnings instead of enforcing.
    #     disabled - No SELinux policy is loaded.
    SELINUX=enforcing
    # SELINUXTYPE= can take one of these two values:
    #     targeted - Targeted processes are protected,
    #     mls - Multi Level Security protection.
    SELINUXTYPE=targeted

    关闭SELinux的方法:
      修改/etc/selinux/config文件中的SELINUX="" 为 disabled ,然后重启。
      如果不想重启系统,使用命令setenforce 0
    注:
    setenforce 1 设置SELinux 成为enforcing模式
    setenforce 0 设置SELinux 成为permissive模式

    2,查看SELinux的模式
    # getenforce
    Enforcing  <==就显示出目前的模式为 Enforcing
     
    3,查看 SELinux 的政策
    # sestatus
    SELinux status:                 enabled    <==是否启动 SELinux
    SELinuxfs mount:                /selinux   <==SELinux 的相关文件资料挂载点
    Current mode:                   enforcing  <==目前的模式
    Mode from config file:          enforcing  <==设定档指定的模式
    Policy version:                 21
    Policy from config file:        targeted  

    【重点】如果要启动SELinux必须满足以下两个点:
    所以,如果你要启动 SELinux 的话,请将上述的 SELINUX=enforcing 设定妥当,并且指定 SELINUXTYPE=targeted 这一个设定, 并且到 /boot/grub/menu.lst 这个文件去,看看核心有无关闭 SELinux 了呢?
    [root@www ~]# vi /boot/grub/menu.lst
    default=0
    timeout=5
    splashimage=(hd0,0)/grub/splash.xpm.gz
    hiddenmenu
    title CentOS (2.6.18-92.el5)
            root (hd0,0)
            kernel /vmlinuz-2.6.18-92.el5 ro root=LABEL=/1 rhgb quiet selinux=0
            initrd /initrd-2.6.18-92.el5.img
    # 如果要启动 SELinux ,则不可以出现 selinux=0 的字样在 kernel 后面!
    【问题】通过上面的学习我们知道,如果将启动着的SELinux改为禁用,需要重启电脑,我们不想重启电脑又不想开启SELinux该怎么办呢?
    【答案】将强制模式改为宽松模!
    [root@www ~]# setenforce [0|1]
    选项与参数:
    0 :转成 permissive 宽容模式;
    1 :转成 Enforcing 强制模式
     
    范例一:将 SELinux 在 Enforcing 与 permissive 之间切换与查看
    [root@www ~]# setenforce 0
    [root@www ~]# getenforce
    Permissive
    [root@www ~]# setenforce 1
    [root@www ~]# getenforce
    Enforcing
     
    6,查看已启动程序的type设定
    [root@master oracle]# ps aux -Z
    LABEL                           USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
    system_u:system_r:init_t        root         1  0.0  0.4   2060   520 ?        Ss   May07   0:02 init [5
    system_u:system_r:kernel_t      root         2  0.0  0.0      0     0 ?        S<   May07   0:00 [migra]
    system_u:system_r:kernel_t      root        11  0.0  0.0      0     0 ?        S<   May07   0:00 [kacpi]
    system_u:system_r:auditd_t      root      4022  0.0  0.4  12128   560 ?        S<sl May07   0:01 auditd
    system_u:system_r:auditd_t      root      4024  0.0  0.4  13072   628 ?        S<sl May07   0:00 /sbin/a
    system_u:system_r:restorecond_t root      4040  0.0  4.4  10284  5556 ?        Ss   May07   0:00 /usr/sb
     
    说明:其实这些东西我们都不用管,都是SELinux内置的。只要学会在强制和宽松模式间转换就行了!

  • 相关阅读:
    .VC中的Attach和Detach
    virtual void DrawItem(LPDRAWITEMSTRUCT /*lpDrawItemStruct*/);
    用API OleLoadPicture通过IStream来加载JPG、GIF格式的图片
    .OnNcHitTest
    线性规划与网络流24题索引
    线性规划与网络流24题 17运输问题
    网络流24题 21最长k可重区间集问题
    网络流16数字梯形问题
    网络流24题 20深海机器人问题
    网络流24题 19负载平衡问题
  • 原文地址:https://www.cnblogs.com/chromebook/p/4121482.html
Copyright © 2011-2022 走看看