CentOS Strem9永久关闭SELINUX和防护墙

[root@localhost ~]# sed -i 's@SELINUX=enforcing@SELINUX=disabled@' /etc/sysconfig/selinux 
[root@localhost ~]# sed -i 's@SELINUX=enforcing@SELINUX=disabled@' /etc/
selinux/config 
[root@localhost ~]# systemctl disable firewalld
Removed "/etc/systemd/system/multi-user.target.wants/firewalld.service".
Removed "/etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service".
[root@localhost ~]# systemctl stop firewalld

CentOS Strem9临时关闭SELINUX和防护墙

[root@localhost ~]# setenforce 0
[root@localhost ~]# getenforce 
Permissive
[root@localhost ~]# 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:          disabled
Policy MLS status:              enabled
Policy deny_unknown status:     allowed
Memory protection checking:     actual (secure)
Max kernel policy version:      33
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# systemctl status firewalld
○ firewalld.service - firewalld - dynamic firewall daemon
     Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disable>
     Active: inactive (dead)
       Docs: man:firewalld(1)

May 14 07:47:09 localhost systemd[1]: Starting firewalld - dynamic fire>
May 14 07:47:10 localhost systemd[1]: Started firewalld - dynamic firew>
May 14 08:09:32 localhost.localdomain systemd[1]: Stopping firewalld - >
May 14 08:09:32 localhost.localdomain systemd[1]: firewalld.service: De>
May 14 08:09:32 localhost.localdomain systemd[1]: Stopped firewalld - d>
...skipping...
○ firewalld.service - firewalld - dynamic firewall daemon
     Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disable>
     Active: inactive (dead)
       Docs: man:firewalld(1)

May 14 07:47:09 localhost systemd[1]: Starting firewalld - dynamic fire>
May 14 07:47:10 localhost systemd[1]: Started firewalld - dynamic firew>
May 14 08:09:32 localhost.localdomain systemd[1]: Stopping firewalld - >
May 14 08:09:32 localhost.localdomain systemd[1]: firewalld.service: De>
May 14 08:09:32 localhost.localdomain systemd[1]: Stopped firewalld - d>
~
~
~
~
~
~
[root@localhost ~]# iptables -F
[root@localhost ~]# iptables -vnL
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         
[root@localhost ~]# reboot
[root@localhost ~]# Connection closing...Socket close.

Connection closed by foreign host.

Disconnected from remote host(192.168.80.201) at 08:10:06.

Type `help' to learn how to use Xshell prompt.

重启服务器后,确认SELINUX和防火墙是否被关闭

[root@localhost ~]# sestatus 
SELinux status:                 disabled // 显示disabled表示selinux已经被关闭了,没有加载
[root@localhost ~]# iptables -vnL
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination      
 // iptables规则链上没有任何规则,表示iptables没有安全规则,忽略即可   
[root@localhost ~]# systemctl status firewalld
○ firewalld.service - firewalld - dynamic firewall daemon
     Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disable>
     Active: inactive (dead) // 状态为dead表示未启动firewalld服务,忽略即可
       Docs: man:firewalld(1)
Logo

北京人形旗下天工造物具身智能开源社区,聚焦具身天工与慧思开物两大平台

更多推荐