Frequently Asked Question

What is /dev/null and why do people redirect output to it?

/dev/null is a special character device provided by the kernel that accepts any data you write to it and immediately discards it, while reads from it always return end-of-file. Linux developers sometimes call it "the bit bucket" or "the digital black hole". It's not a regular file, it never grows, never wears the disk, and any number of processes can write to it at once.

You redirect to /dev/null whenever you want to silence output you don't care about. command 2>/dev/null suppresses error messages; command >/dev/null suppresses normal output (useful when you only want the exit code); command &>/dev/null silences both. You can also read from it: cat </dev/null gives a program an empty input, which is handy when you want it to terminate immediately or you're testing how it handles EOF.

Further reading and video