bash: iptables: 命令未找到

use*_*167 19 iptables path

如何解决iptables: command not foundDebian 7.6 发生的问题?

batman@gotham:~$ uname -a
Linux gotham 3.14-0.bpo.2-amd64 #1 SMP Debian 3.14.13-2~bpo70+1 (2014-07-31) x86_64 GNU/Linux
batman@gotham:~$ iptables -L
bash: iptables: command not found
batman@gotham:~$ sudo apt-get install iptables
[sudo] password for batman: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
iptables is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
batman@gotham:~$
Run Code Online (Sandbox Code Playgroud)

我在谷歌上进行了广泛的搜索,大部分答案都是针对可追溯到 2005 年和 2009 年的 CentOS 和 Fedora。

Gil*_*il' 18

iptables命令几乎只能以 root 身份运行,而不能以其他用户身份运行。所以它不在 root 以外的用户的默认命令搜索路径中。

要运行iptables,请使用以下任一命令以 root 身份运行它:

su 'iptables --some-option …'
sudo iptables --some-option …
Run Code Online (Sandbox Code Playgroud)

可执行文件位于 中/sbin,它位于root 的默认命令搜索路径中。


fle*_*rus 9

这是因为iptables没有列在您的PATH变量中。我认为它应该与sudo命令一起使用。尝试:

sudo iptables -L
Run Code Online (Sandbox Code Playgroud)

如果这也不起作用,那么您应该检查iptables二进制文件的位置,然后将其添加到PATH变量中。

在大多数情况下,它应该在/sbin/. 不过,只需在 Debian7 中验证即可。如果它在,/sbin/那么你可以打开.bashrc文件并在最后提供:

PATH=/sbin/:$PATH
Run Code Online (Sandbox Code Playgroud)

  • 嗯,这些是基础知识。好的,它在您的主目录中。尝试从您的终端打开。`vim ~/.bashrc` (2认同)