How do I fix the iptables: command not found problem that happened to Debian 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.

I googled extensively and most of the answers were for CentOS and Fedora that dated back to 2005 and 2009.

  • What's the output of echo $PATH? – Braiam Aug 16 '14 at 11:44
  • 1
    iptables should be in your PATH so it is the sudo you are missing. – Valentin Bajrami Aug 16 '14 at 12:19

The iptables command can pretty much only be usefully run as root, not as another user. So it is not in the default command search path for users other than root.

To run iptables, run it as root, with either of these commands:

su 'iptables --some-option …'
sudo iptables --some-option …

The executable is located in /sbin, which is in the default command search path for root.


It's because iptables is not listed in your PATH variable. I think it should work with the sudo command. Try:

sudo iptables -L

If that too doesn't work then you should checkout where the iptables binary is and then add it to the PATH variable.

In most cases it should be in /sbin/. Still, just verify in Debian7. If it is in /sbin/ then you can open .bashrc file and provide this at the end:

  • you should checkout where the iptables binary is What command should I type to locate the iptables binary? – user70167 Aug 16 '14 at 12:19
  • then you can open .bashrc file and Where is the location of .bashrc file? – user70167 Aug 16 '14 at 12:20
  • 1
    did you check with sudo? Try dpkg -L iptables to list out the files. – flemingovirus Aug 16 '14 at 12:20
  • What about .bashrc file? Where's it located? – user70167 Aug 16 '14 at 13:07
  • 2
    Well these are the basics. Ok it is in your home directory. Trying opening from your terminal. vim ~/.bashrc – flemingovirus Aug 16 '14 at 13:08

dpkg -L iptables will show where the files are installed from the package iptables.

dpkg -L iptables | grep iptables$

You can check the location of iptables binary file. For me on Ubuntu it is in /sbin/iptables.

So run with /sbin/iptables -L and check.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.