Quiz Entry - updated: 2026.07.14
What is /dev/null and how is it used?
/dev/null is a special device file that discards everything written to it — redirect a stream there to silence it.
/dev/null is the system's "black hole": anything you write vanishes, and reading from it gives instant end-of-file. Because it behaves like a file, you can aim any redirect at it. The most common use is killing error noise: 2> /dev/null throws away stderr so find / doesn't bury you in "Permission denied". > /dev/null 2>&1 drops all output — useful in cron jobs where you only care whether the command succeeded, not what it printed.
Common use - suppress error messages:
find / -name "passwd" 2> /dev/null
Use cases:
| Pattern | Purpose |
|---|---|
2> /dev/null |
Discard errors only |
> /dev/null |
Discard stdout only |
> /dev/null 2>&1 |
Discard all output |
Example:
# Search without "Permission denied" spam:
find / -name "*.conf" 2> /dev/null
Tip: /dev/null is often called the "bit bucket" - bits go in, nothing comes out.