Linux如何啟動SELinux
Linux啟動SELinux
centos
centos自帶SELinux。
檢查SELinux是否開啟
root@ubuntu:/home/wenyao/Desktop# getenforce Permissive #如果是disabled證明是未開啟,而(enforcing,permissive,不同模式)證明已經(jīng)開啟
開啟
先編輯/etc/selinux/config
配置信息
- 強制模式
SELINUX=enforcing
:表示所有違反安全策略的行為都將被禁止。 - 寬容模式
SELINUX=permissive
:表示所有違反安全策略的行為不被禁止,但是會在日志中作記錄。
# 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. #改為permissive(測試一般是permissive模式,會有警告提醒) SELINUX=permissive # SELINUXTYPE= can take one of three two values: # targeted - Targeted processes are protected, # minimum - Modification of targeted policy. Only selected processes are protected. # mls - Multi Level Security protection. SELINUXTYPE=targeted
在根目錄下創(chuàng)建隱藏文件.autorelabel
,然后重啟Linux
#新建標志文件 touch /.autorelabel #重啟 reboot
驗證
#查看模式 root@ubuntu:/home/wenyao/Desktop# getenforce #查看SELinux狀態(tài) root@ubuntu:/home/wenyao/Desktop# sestatus
切換SELinux模式
模式切換不需要重啟linux,而在關(guān)閉SELinux(設(shè)為disabled)或開啟(設(shè)為permissive,Enforcing)需要重啟Linux。
#將 SELinux 在 Enforcing 與 permissive 之間切換(不需要重啟) #0 : 轉(zhuǎn)成permissive 寬容模式 #1 : 轉(zhuǎn)成Enforcing 強制模式 #切換為寬容模式 setenforce 0 #想關(guān)閉只能去改配置文件/etc/selinux/config(需要重啟) vim /etc/selinux/config
Utunbu
安裝SELinux
,Utunbu
似乎不是自帶SELinux
的,而是使用AppArmor
代替。
本人在Utunbu20.4
測試,發(fā)現(xiàn)只有AppArmor
,所以我需要使用SELinux
進行替換。
安裝SELinux
#暫停apparmor sudo systemctl stop apparmor #卸載apparmor sudo apt purge apparmor #更新apt源 sudo apt update #安裝SELiunx需要的包 sudo apt install policycoreutils selinux-utils selinux-basics #驗證安裝成功(會被告知你需要重啟) sudo selinux-activate #重啟 reboot
開啟
也是/etc/selinux/config
配置信息,會發(fā)現(xiàn)跟centos那邊的SELinux的配置文件有一些些不同,不過主題內(nèi)容大致一致。
# 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. #默認是premissive SELINUX=permissive # SELINUXTYPE= can take one of these two values: # default - equivalent to the old strict and targeted policies # mls - Multi-Level Security (for military and educational use) # src - Custom policy built from source SELINUXTYPE=default # SETLOCALDEFS= Check local definition changes SETLOCALDEFS=0
驗證
驗證方式?jīng)]改變
root@ubuntu:/home/wenyao/Desktop# getenforce Permissive root@ubuntu:/home/wenyao/Desktop# sestatus SELinux status: enabled SELinuxfs mount: /sys/fs/selinux SELinux root directory: /etc/selinux Loaded policy name: default Current mode: permissive Mode from config file: permissive Policy MLS status: enabled Policy deny_unknown status: allowed Memory protection checking: requested (insecure) Max kernel policy version: 33
切換SELinux模式
跟Centos一樣。
總結(jié)
以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
關(guān)于安裝LNMP集成包后上傳圖片報500錯誤的解決方法
這篇文章主要給大家介紹了關(guān)于安裝LNMP集成包后上傳圖片報500錯誤的解決方法,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧。2018-01-01Linux初學(xué)(CnetOS7 Linux)之切換命令模式和圖形模式的方法
本篇文章主要介紹了Linux初學(xué)(CnetOS Linux7)之切換命令模式和圖形模式的方法,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-03-03Ubuntu系統(tǒng)下安裝ImageMagick出錯的解決過程
由于項目需要, 所以要在Ubuntu下面安裝ImageMagick,但在安裝過程中遇到了些問題,通過查找相關(guān)的資料最終得以解決了,所以下面這篇文章主要給大家介紹了關(guān)于Ubuntu系統(tǒng)下安裝ImageMagick出錯的解決過程,需要的朋友可以參考借鑒,下面來一起看看吧。2017-07-07Centos7 Mysql 5.6 多主一從 解決方案與詳細配置
這篇文章主要介紹了Centos7 Mysql 5.6 多主一從 解決方案與詳細配置,需要的朋友可以參考下2016-04-04