linux中如何關閉 開啟SElinux

2022-09-19 22:09:21 字數 4581 閱讀 3680

1、檢視核心、系統版本

[root@virtualboxcentos7 test]# hostnamectl

static hostname: virtualboxcentos7

icon name: computer-vm

chassis: vm

machine id: e8d08b54fc55254aaefd55597b2e435b

boot id: f308a2863585439cb4c69007b56ad527

virtualization: kvm

operating system: centos linux

7(core) ## 發行版

cpe os name: cpe:/o:centos:centos:7

kernel: linux

3.10.0-1160.49.1

.el7.x86_64 ## 核心

architecture: x86-64

2、檢視當前的selinux狀態,sestatus命令

[root@virtualboxcentos7 test]# sestatus  ## 使用sestatus檢視

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

max kernel policy version:

31

3、臨時關閉(系統重啟後仍然後啟動selinux)

[root@virtualboxcentos7 test]# sestatus  ## 檢視當前狀態

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

max kernel policy version:

31[root@virtualboxcentos7 test]# setenforce

0 ## 臨時關閉selinux

[root@virtualboxcentos7 test]# sestatus ## 檢視狀態

selinux status: enabled

selinuxfs mount: /sys/fs/selinux

selinux root directory: /etc/selinux

loaded policy name: targeted

current mode: permissive ## 由enforcing 變為了 permissive

mode

from

config file: enforcing

policy mls status: enabled

policy deny_unknown status: allowed

max kernel policy version:

31

4、重新開啟selinux

[root@virtualboxcentos7 test]# sestatus   ## 檢視狀態

selinux status: enabled

selinuxfs mount: /sys/fs/selinux

selinux root directory: /etc/selinux

loaded policy name: targeted

current mode: permissive

mode

from

config file: enforcing

policy mls status: enabled

policy deny_unknown status: allowed

max kernel policy version:

31[root@virtualboxcentos7 test]#setenforce

1 ## 開啟selinux

[root@virtualboxcentos7 test]#sestatus ## 檢視狀態

selinux status: enabled

selinuxfs mount: /sys/fs/selinux

selinux root directory: /etc/selinux

loaded policy name: targeted

current mode: enforcing ## 由permissive 改為了 enforcing

mode

from

config file: enforcing

policy mls status: enabled

policy deny_unknown status: allowed

max kernel policy version:

31

5、修改配置檔案,永久關閉selinux

[root@virtualboxcentos7 test]# vim /etc/sysconfig/

selinux

# 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=disabled ## 此處改為disabled, 然後儲存退出

6、重啟系統、檢查

[root@virtualboxcentos7 test]# reboot

[root@virtualboxcentos7 test]# sestatus

selinux status: disabled

[root@virtualboxcentos7 test]# getenforce ## 說明已經禁用selinux

disabled

7、如果永久開啟,在/etc/sysconfig/selinux配置檔案中disabled改為enforcing,然後重啟系統即可

doc開啟關閉mysql 如何開啟 關閉資料庫歸檔

1 單機模式下 如果開啟歸檔,請保證 log archive start true 開啟自動歸檔,否則只能手工歸檔,如果是關閉了歸檔,則設定該引數為false。10g之後廢除該引數,不需要設定。log archive dest 歸檔日誌存放路徑 alter system set log archiv...

C 如何開啟關閉CDROM

using system using system.text using system.runtime.interopservices class closecd dllimport winmm.dll entrypoint mcisendstringa charset charset.ansi p...

如何開啟或關閉SELinux

centos的 etc sysconfig selinux 修改檔案 etc sysconfig selinux this file controls the state of selinux on the system.selinux can take one of these three val...