Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

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 know I can redirect the error messages from a command to /dev/null using the following syntax:

command arg1 arg2 2>/dev/null

But is there a way to do this by default so that the error messages always go to /dev/null, unless I specify otherwise?

share|improve this question
In short: yes - redirect /dev/stderr to /dev/null. But, if you can't figure it out on your own, you shouldn't try, as you are more likely to break something fatally than succeed. – Benubird May 13 '13 at 8:11
@Benubird stderr != /dev/stderr. Redirecting that file won't do anything. The file in /dev/ is just for convenience. – Chris Down May 14 '13 at 3:51
@ChrisDown you're right, /dev/stderr is just a link. Still, a lot of processes write to that instead of fd/2, which you could also redirect. It gets more complicated from there - which is why I left a comment instead of an answer :). – Benubird May 14 '13 at 8:11

Lots of programs send output to stderr that isn't actually indicative of errors. For example, in some programs it is used to display information that would otherwise affect the output of the program (which is designed to be piped into another program). You can, however, do this:

exec 2>/dev/null

I wouldn't recommend doing this outside of a script.

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.