/dev is the directory containing device files—special nodes through which programs interact with hardware and kernel-provided virtual devices. Reading from or writing to a device file is translated by the kernel into calls to the appropriate driver. Classic examples include /dev/sda (a disk), /dev/tty1 (a virtual console), /dev/null (a data sink), /dev/zero (a source of zeros), /dev/random and /dev/urandom (random bytes), and /dev/loop0 (loopback devices).
Originally /dev was a plain directory full of hand-created device nodes (mknod statically created thousands of them at install time). Modern Linux uses devtmpfs, a kernel-managed filesystem that populates /dev automatically with nodes for every detected device. On top of that, the udev daemon creates named symlinks, sets permissions, and triggers scripts when devices are added or removed—allowing rules like "whenever this specific USB stick is plugged in, mount it at /media/backup."
Useful idioms include dd if=/dev/zero of=file bs=1M count=100 to create a 100 MB file of zeros, cp /dev/null file.log to truncate a file, and cat /dev/urandom | base64 | head -c 32 to generate a password. Every terminal your shell is running in corresponds to a /dev/pts/N or /dev/tty entry, visible with tty.
Related terms: Device File, /dev/null, /dev/zero, /dev/random
Discussed in:
- Chapter 4: The Filesystem Hierarchy — /proc, /sys, /dev, /run — Pseudo-filesystems
Also defined in: Textbook of Linux