大网数据广告活动
服务器运维问答

running systemctl with sudo throws "Failed to execute operation: No such file or directory"

· 52CE 我爱测

I am trying to disable firewall on CentOS7.3 on Azure with the following: sudo systemctl disable iptables-services firewalld Unfortunately I get the following error: "Failed to execute operation: No such file or directory" What i…

问题原文

原帖链接 · Lech Migdal · CC BY-SA 3.0

I am trying to disable firewall on CentOS7.3 on Azure with the following:

sudo systemctl disable iptables-services firewalld

Unfortunately I get the following error:

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

What is interesting is that when I run this without sudo, OS seems to be finding the files and I get the following:

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

But then I fail at authentication (since root account is disabled, I login with SSH key).

Any suggestions how to move forward are appreciated :)

已采纳解答

原帖链接 · iwaseatenbyagrue · CC BY-SA 3.0

I think you might be using the wrong service name for the iptables service.

Also, if you have a default centos install, I would assume firewalld is in place (rather than the iptables _service) - so if you really want to stop all firewalling, probably systemctl stop firewalld will do for now (and systemctl disable firewalld if you really mean to do that).

Easiest is probably to confirm that part is correct:

sudo systemctl | grep iptable

The error message is down to the fact there is no unit file found called iptables-services.service, in any of systemd's search paths.

To quickly illustrate:

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

vs something that does exist:

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

The path shown is not the only one that systemd looks at, in passing.

Unless you are doing this to install a different firewall manager/front-end, I would however tend to want to suggest leaving firewalld in place, and open the ports you need.

Firewalld is fairly straightforward (see docs: http://www.firewalld.org/), and opening up a specific port is a simple matter of (again, assuming default centos7): sudo firewall-cmd --zone public --add-port=PORT/PROTO --permanent && sudo firewall-cmd reload

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-03-03)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。