Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have an irritating problem: redirecting stderr does not work. I get:

iptables: Chain already exists

I can't be bothered to check if a chain exists already (pointless, iptables just throws an error if the chain exists before I flush it in the next step, so why bother checking if it already exists). In order to ignore this, I redirect stderr to /dev/null but this does not seem to work.

In general: how do I:

  1. check which stream is used by a command in bash? is this even possible?

  2. redirect ALL streams output by a command?

share|improve this question
Yikes! layman error: i was redirecting stderr before redirecting stdout: iptables -N droplist 2>&1 >/dev/null iptables: Chain already exists iptables uses stderr on error, "iptables -N droplist >/dev/null 2>&1" works. Nevertheless, the questions still stand I think. – LetMeSOThat4U Jul 8 '13 at 10:42
You might be interested in "netstat -tnlp" – Synthead Jul 24 '13 at 19:45
  • what is your iptables command?

  • you can look at /proc/<pid>/fd/ ! there are "pipe" entries with a pid of another command involved in the command chain

  • redirecting all streams in bash according to TFM:

    There are two formats for redirecting standard output and standard error:
    Of the two forms, the first is preferred. This is semantically equivalent to
    >word 2>&1

Stefan K.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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