0

Once I tried command..

sudo iptables-save > /etc/iptables/rules.v4

..to save iptables to some file. Its interesting that I failed to run this command: it said I have insufficient permissions. The file itself was not available for writing for my user. But was available for sudo, of course. Looks like sudo is not passed to next pipelines in a row of commands. How can we fix it?

MiamiBeach
  • 203
  • 1
  • 3
  • 7
  • 1
    See [my answer to the linked duplicate](https://superuser.com/a/1217399/432690). In your case you probably want `sudo iptables-save | sudo tee /etc/iptables/rules.v4 > /dev/null`. The [other answer](https://superuser.com/a/1217402/432690) is on the right track, but it's clumsy; the right alternative way is `sudo sh -c 'iptables-save > /etc/iptables/rules.v4'`. – Kamil Maciorowski Feb 03 '23 at 22:05

0 Answers0