What is stored in the /dev directory?
/dev contains "device files" — special entries that let you talk to hardware (and some virtual devices) as if they were ordinary files you read from and write to.
This embodies the Unix mantra "everything is a file." Instead of inventing a separate API for disks, terminals, and sound cards, Linux exposes each device as a file in /dev. Reading from /dev/sda reads raw bytes off the disk; writing to a printer device sends it data. One simple model — open, read, write — covers wildly different hardware.
| Device file | Represents |
|---|---|
/dev/sda, /dev/sda1 |
First disk, and its first partition |
/dev/null |
A black hole — swallows anything written, returns nothing |
/dev/zero |
An endless stream of zero bytes |
/dev/random |
A source of random bytes |
/dev/tty |
Your current terminal |
The "virtual" devices are quietly some of the most useful tools on the system:
command > /dev/null # throw away output you don't want to see
dd if=/dev/zero of=file.bin bs=1M count=1 # make a 1 MB file filled with zeros
Why this matters: because devices are files, all the normal file tools — redirection, cat, permissions — just work on hardware. /dev/null as a "discard" target is something you'll use constantly.
Mnemonic: dev = devices.