I've been using the following to launch programs from terminals:

program_name >/dev/null 2>&1 &

But recently I came across this webpage where the following method was recommended:

program_name </dev/null &>/dev/null &

Now, I know what the first one means. It means to point stderr to stdout and stdout to /dev/null i.e. both stderr and stdout is now pointed to null.

But what does the second one means? And which one is more suitable for launching programs headlessly from terminal?

2 Answers 2


There are, by default, three "standard" files open when you run a program, standard input (stdin), standard output (stdout), and standard error (stderr). In Unix, those are associated with "file descriptors" (stdin = 0, stdout = 1, stderr = 2). By default, all three are associated with the device that controls your terminal (the interface through which you see content on screen and type input into the program).

The shell gives you the ability to "redirect" file descriptors. The > operator redirects output; the < redirects input.

For example:

program_name > /dev/null

Which is equivalent to:

program_name 1> /dev/null

Redirects the output to file descriptor 1 ('stdout') to `/dev/null'


program_name 2> /dev/null

Redirects the output to file descriptor 2 ('stderr') to '/dev/null'

You might want to redirect both stdout and stderr to a single file, so you might think you'd do:

program_name > /dev/null 2> /dev/null

But that doesn't handle interleaving writes to the file descriptors (the details behind this are a different question). To address this, you can do:

program_name > /dev/null 2>&1

Which says "redirect writes to file descriptor 1 to /dev/null and redirect writes to file descriptor 2 to the same place as the writes to file descriptor 1 are going". This handles interleaving writes to the file descriptors.

That option is so common that some shells include a short-hand that is shorter and functionally equivalent:

program_name &> /dev/null

Finally, you can redirect input in the same way that you redirect output:

program_name < /dev/null

Will redirect file descriptor 0 (stdin) from /dev/null, so if the program tries to read input, it'll get EOF.

Putting that all together:

program_name </dev/null &>/dev/null &

Say (1) run program_name, (2) redirect standard input from /dev/null (</dev/null), (3) redirect both file descriptors 1 and 2 (stdout and stderr) to /dev/null (&>/dev/null), and (4) run the program in the background (&).

  • Why does & in &>/dev/null means fd 1 and fd 2? Is that the short-hand you talked about above this ending?
    – 3N4N
    Jan 28, 2019 at 14:54
  • 1
    The last & is to run the program in the background -- it's unrelated to redirection. > redirects standard output; 2> redirects standard error. Jan 28, 2019 at 15:12
  • is program_name </dev/null >/dev/null 2>&1 & equivalent to program_name </dev/null &>/dev/null &?
    – 3N4N
    Jan 28, 2019 at 15:18
  • 1
    Yes, like I said in my answer above, foo &> bar is a short-hand for foo > bar 2&1. The < /dev/null means the same in both instances. Jan 28, 2019 at 15:48

For > /dev/null You are actually nullifying the thing.

While for 2>&1 You are redirecting any error stream text to the output stream. This will be best understand when someone tries to run a command that actually throws error when executed. Just use that command twice once as it is and another time with 2>&1 post your command.

Hope this will help at least novice users. Thanks.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .