CentOS 8 關閉 Firewalld 及 SELinux
阿新 • • 發佈:2021-06-29
檢查 SELinux 是否開啟
執行 sestatus 指令可以檢視目前 SELinux 的狀態, 其中一項是是否有開啟, 執行以下指令:
# sestatus | grep status
如果看到 enabled 表示開啟, disabled 表示關閉.
關閉 SELinux:
執行以下指令關閉 SELinux:
# setenforce 0
這樣便會把 SELinux 暫時關閉, 下次重新開機後會自動重新開啟.
如果需要下次開機後還會關閉, 需要編輯檔案 /etc/selinux/config:# vi /etc/selinux/config
找到以下一行:
SELINUX=enforce
改成:
SELINUX=disabled
另外將 “SELINUXTYPE=targeted” 加上註釋, 改成這樣:
# SELINUXTYPE=targeted
儲存後離開編輯器, 下次重新開機後 SELinux 也會關閉。
關閉 Firewalld 防火牆:
Firewalld 是 RHEL 及 CentOS 預設的防火牆, 只要用 systemctl 便可關閉及停用:
關閉 Firewalld 防火牆:
# systemctl stop firewalld.service
設定下次開機不會啟動 Firewalld 防火牆:
# systemctl disable firewalld.service