Table of Contents
/dev
/dev is the directory that exposes hardware devices and kernel abstractions as files. Reading and writing a file in /dev communicates directly with a device driver. This is the “everything is a file” principle made concrete: a disk, a terminal, a random number generator, and a null sink all appear as regular file paths that ordinary open/read/write/close calls work on.
Device files come in two kinds. Block devices (b in ls -l) transfer data in fixed-size chunks and support seeking; disks and partitions are block devices (/dev/sda, /dev/nvme0n1). Character devices (c) transfer data as a stream without seeking; terminals, serial ports, and input devices are character devices (/dev/tty, /dev/ttyS0, /dev/input/event0). Each device file has a major number (identifies the driver) and a minor number (identifies the specific device instance).
/dev/sda block device: first SATA/SCSI disk /dev/sda1 block device: first partition of sda /dev/nvme0n1 block device: first NVMe disk /dev/tty char device: controlling terminal of the current process /dev/ttyS0 char device: first serial port (COM1) /dev/null char device: discards all writes; reads return EOF /dev/zero char device: reads return an infinite stream of zero bytes /dev/urandom char device: reads return cryptographically secure random bytes /dev/mem char device: direct access to physical memory (requires root)
/dev is populated dynamically by udev (or devtmpfs in the kernel). When the kernel detects new hardware, it emits a uevent; udev receives it and creates the corresponding file in /dev with the correct permissions and symlinks. Plug in a USB drive and /dev/sdb appears; unplug it and the file disappears.
