使用sudo throws运行systemctl“无法执行操作:没有这样的文件或目录”

我正尝试在Azure上的CentOS7.3上禁用防火墙,如下所示:

sudo systemctl disable iptables-services firewalld 

不幸的是我得到以下错误:

 "Failed to execute operation: No such file or directory" 

有趣的是,当我运行这个没有sudo,操作系统似乎是find这些文件,我得到以下几点:

 ==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-unit-files === Authentication is required to manage system service or unit files. Authenticating as: root 

但是,然后我authentication失败(因为root帐户被禁用,我用SSH密钥login)。

任何build议如何前进是赞赏:)

我想你可能会使用错误的服务名称为iptables服务。

此外,如果你有一个默认的centos安装,我会假设firewalld到位(而不是iptables _service) – 所以如果你真的想停止所有的防火墙,可能systemctl stop firewalld将现在做(和systemctl disable firewalld如果你真的意味着做到这一点)。

最简单的可能是确认部分是正确的:

sudo systemctl | grep iptable

错误消息是在systemd的任何searchpath中找不到称为iptables-services.service的单元文件。

为了快速说明:

sudo systemctl status nosuchthing Unit nosuchthing.service could not be found.

vs确实存在的东西:

sudo systemctl status sshd sshd.service - OpenSSH server daemon Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled)

所显示的path并不是系统所看到的唯一path。

除非你这样做来安装不同的防火墙pipe理器/前端,否则我会倾向于build议离开firewalld,并打开你需要的端口。

Firewalld相当简单(参见文档: http : //www.firewalld.org/ ),开放一个特定的端口是一个简单的事情(再次假设默认的centos7): sudo firewall-cmd --zone public --add-port=PORT/PROTO --permanent && sudo firewall-cmd reload