[精讚] [會員登入]
3572

SELinux 常用指令和檔案

在Redhat系列中,Centos5以後加入了selinux,他並沒有這麼可怕,不必每次看到Selinux ,就想把他

分享此文連結 //n.sfs.tw/10055

分享連結 SELinux 常用指令和檔案@新精讚
(文章歡迎轉載,務必尊重版權註明連結來源)
2019-10-25 13:45:11 最後編修
2016-10-22 09:20:18 By 張○○
 

自動目錄

在Redhat系列中,Centos5以後加入了selinux,他並沒有這麼可怕,不必每次看到Selinux ,就想把他 Disable

SELinux的三種模式[2]

  • enforcing:強制模式,代表 SELinux 運作中;
  • permissive:寬容模式:代表 SELinux 運作中,不過僅會有警告訊息並不會實際限制存取。這種模式可以運來作為 SELinux 的 debug 之用;
  • disabled:關閉,SELinux 並沒有實際運作。

和SElinux 有關的指令

sestatus 顯示 SELinux 的狀態
# sestatus
SELinux status:                 enabled
SELinuxfs mount:                /selinux
Current mode:                   enforcing
Mode from config file:          enforcing
Policy version:                 21
Policy from config file:        targeted

參數

-v
-b  顯示 selinux 的policy boolean 值

setenforce 強制啟動或停止 SElinux,只能設 enforcing和permissive兩種狀態

# setenforce 1
# sestatus
SELinux status:                 enabled
SELinuxfs mount:                /selinux
Current mode:                   enforcing
Mode from config file:          enforcing
Policy version:                 24
Policy from config file:        targeted
# setenforce 0
# sestatus
SELinux status:                 enabled
SELinuxfs mount:                /selinux
Current mode:                   permissive
Mode from config file:          enforcing
Policy version:                 24
Policy from config file:        targeted

setsebool  設定 SElinux 的全域 boolean 值

getsebool 取得 SElinux 的全域 boolean 值

# getsebool  virt_use_comm
virt_use_comm --> off
# setsebool  virt_use_comm on
# getsebool  virt_use_comm
virt_use_comm --> on

chcon 改變檔案之 selinux 權限屬性

# chcon -t httpd_user_content_t n.sfs.tw.css

fixfiles 修正檔案之 selinux context 內文

ls 列出檔案 selinux 權限

參數

--lcontext
        Display security context.   Enable -l. Lines will probably be too wide for most  dis-
        plays.
-Z, --context
        Display  security  context  so  it  fits on most displays.  Displays only mode, user,
        group, security context and file name.
--scontext
        Display only security context and file name.
--help display this help and exit
--version
       output version information and exit

和 SElinux 有關的檔案

/etc/selinux/config    selinux 的設定

/etc/sestatus.conf    selinux 的全域boolean 值

參考資料

[1] 安全增強式Linux(SELinux, Security-Enhanced Linux)

[2] 鳥哥對 selinux 的說明,非常詳細 http://linux.vbird.org/linux_basic/0440processcontrol.php#selinux


原文編修 2009-10-09 21:53:32

END

你可能感興趣的文章

[CentOS 8] 無法使用: No URLs in mirrorlist error Centos8 沒辦法使用yum安裝軟體的解決方法

[CentOS6] 設定 sendmail Centos6上設定sendmail,基本上sendmail會設定多半是為了寄系統信和收垃圾信(喂!!?)

[Centos] 安裝及設定docker docker 是一個應用程式的容器,相對於vm是作業系統的容器。此篇整理基本安裝及設定。

dnf 一個即將取代 yum的套件管理程式 centos 系統中老牌的套件管理程式yum,也許未來將被dnf所取代

[Centos] Linux mount 掛載檔案時的使用者和SELINUX和權限處理 linux下使用mount來掛載目錄或磁碟,我們一般會使用這樣的指令 # mount /dev/sdc1 /home/h

[MSSQL] 使用linux連接微軟的MS-SQL 職務上需要連接到mssql,這是我第一次試圖在linux連接mssql。

我有話要說

>>

限制:留言最高字數1000字。 限制:未登入訪客,每則留言間隔需超過10分鐘,每日最多5則留言。

訪客留言

[無留言]

隨機好文

[Freebsd] 定時測試 ADSL 是否斷線並重連 中華電信 ADSL 雖有固定 ip,可是他卻會不定時「斷線」, 使用以下的 方法可以定時測試是否斷線,以及重新撥接。

UTF8中文字/全形一覽 快速查詢urf-8的中文字,共計13246中文字(5401常用字+7652罕用字+日文或編號),292全形符號,27半形符號。

[AS3] 變數型態 基本類型宣告 as3 有下列幾種基本類型:string, int, number, object, boolean, n

在Centos7 下安裝 Wildfly10 wildfly以前叫JBoss,2014.11.20改名叫Wildfly,起始版本是Wildfly8,現在已經出到Wil

安裝git centos/freebsd/windows安裝git