CentOS防火牆開啟失敗怎麼解決
#突然發現centos 7 的防火牆無法啟動,且firewall-cmd指令運行報錯,防火牆啟動報錯如下:
[root@localhost firewalld]# systemctl start firewalld.service Job for firewalld.service failed because the control process exited with error code. See "systemctl status firewalld.service" and "journalctl -xe" for details. [root@localhost firewalld]# systemctl status firewalld.service ● firewalld.service - firewalld - dynamic firewall daemon Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled) Active: failed (Result: exit-code) since 三 2020-01-08 10:43:48 CST; 10s ago Docs: man:firewalld(1) Process: 29630 ExecStart=/usr/sbin/firewalld --nofork --nopid $FIREWALLD_ARGS (code=exited, status=127) Main PID: 29630 (code=exited, status=127)
firewall-cmd指令執行報錯如下:(建議學習:Linux影片教學)
[root@localhost yangl]# firewall-cmd Traceback (most recent call last): File "/usr/bin/firewall-cmd", line 24, in <module> from gi.repository import GObject ImportError: No module named gi.repository
究其原因是因為使用了自訂安裝的python,並將自己安裝的python作為預設python導致(此外,將系統預設的python升級為python3也可能會出現類似問題),因此只需將firewalld和firewall-cmd第一行呼叫的python改為系統的python即可解決。
我的python連結方式如下:
[root@localhost yangl]# cd /usr/bin/ [root@localhost bin]# ll python* lrwxrwxrwx. 1 root root 16 9月 28 2018 python -> /usr/bin/python2 lrwxrwxrwx. 1 root root 39 9月 28 2018 python2 -> /share/soft/python-2.7.15/bin/python2.7 -rwxr-xr-x. 1 root root 7216 7月 13 2018 python2.7 #系统的python lrwxrwxrwx. 1 root root 9 9月 28 2018 python2_old -> python2.7 lrwxrwxrwx. 1 root root 36 3月 7 2018 python3 -> /share/soft/python-3.6.4/bin/python3 lrwxrwxrwx. 1 root root 7 9月 28 2018 python_old -> python2
因此,只需vi打開/usr/sbin/firewalld 和/usr/bin/firewall-cmd,將其中的第一行由# !/usr/bin/python -Es 改為#!/usr/bin/python2.7 -Es 即可!
這篇文章來自PHP中文網,CentOS使用教學欄目,更多相關教學請關注本專欄!
以上是CentOS防火牆開啟失敗怎麼解決的詳細內容。更多資訊請關注PHP中文網其他相關文章!

CentOS的替代方案包括UbuntuServer、Debian、Fedora、RockyLinux和AlmaLinux。 1)UbuntuServer適合基本操作,如更新軟件包和配置網絡。 2)Debian適用於高級用法,如使用LXC管理容器。 3)RockyLinux可通過調整內核參數優化性能。

CentOS 關機命令為 shutdown,語法為 shutdown [選項] 時間 [信息]。選項包括:-h 立即停止系統;-P 關機後關電源;-r 重新啟動;-t 等待時間。時間可指定為立即 (now)、分鐘數 ( minutes) 或特定時間 (hh:mm)。可添加信息在系統消息中顯示。

CentOS 和 Ubuntu 的關鍵差異在於:起源(CentOS 源自 Red Hat,面向企業;Ubuntu 源自 Debian,面向個人)、包管理(CentOS 使用 yum,注重穩定;Ubuntu 使用 apt,更新頻率高)、支持週期(CentOS 提供 10 年支持,Ubuntu 提供 5 年 LTS 支持)、社區支持(CentOS 側重穩定,Ubuntu 提供廣泛教程和文檔)、用途(CentOS 偏向服務器,Ubuntu 適用於服務器和桌面),其他差異包括安裝精簡度(CentOS 精

CentOS 中配置 IP 地址的步驟:查看當前網絡配置:ip addr編輯網絡配置文件:sudo vi /etc/sysconfig/network-scripts/ifcfg-eth0更改 IP 地址:編輯 IPADDR= 行更改子網掩碼和網關(可選):編輯 NETMASK= 和 GATEWAY= 行重啟網絡服務:sudo systemctl restart network驗證 IP 地址:ip addr

CentOS 安裝步驟:下載 ISO 映像並刻錄可引導媒體;啟動並選擇安裝源;選擇語言和鍵盤佈局;配置網絡;分區硬盤;設置系統時鐘;創建 root 用戶;選擇軟件包;開始安裝;安裝完成後重啟並從硬盤啟動。

重啟 SSH 服務的命令為:systemctl restart sshd。步驟詳解:1. 訪問終端並連接到服務器;2. 輸入命令:systemctl restart sshd;3. 驗證服務狀態:systemctl status sshd。

在 CentOS 8 中重啟網絡需執行以下步驟:停止網絡服務(NetworkManager)重新加載網絡模塊(r8169)啟動網絡服務(NetworkManager)檢查網絡狀態(通過 ping 8.8.8.8)

重啟 CentOS 7 可使用 reboot 命令。步驟如下:打開終端窗口並輸入 reboot 命令。確認重啟提示。系統將重啟,期間會出現引導菜單。重啟完成後,使用憑據登錄。


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

AI Hentai Generator
免費產生 AI 無盡。

熱門文章

熱工具

Dreamweaver Mac版
視覺化網頁開發工具

SublimeText3 英文版
推薦:為Win版本,支援程式碼提示!

記事本++7.3.1
好用且免費的程式碼編輯器

Atom編輯器mac版下載
最受歡迎的的開源編輯器

SAP NetWeaver Server Adapter for Eclipse
將Eclipse與SAP NetWeaver應用伺服器整合。