Frequently Asked Question
What are the files in /dev and what's the difference between block and character devices?
/dev holds device files: special files that the kernel uses as handles for hardware
and pseudo-hardware. Reading /dev/sda gives you the raw bytes of the first SATA disk;
writing to /dev/null discards them; reading /dev/urandom gives you a stream of
cryptographic-quality random bytes. The ls -l listing shows the type as the first
character: b for block devices and c for character devices. After the permissions
come two numbers, like 8, 0, which are the major and minor device numbers, the
kernel uses them to look up which driver handles the device.
Block devices (disks, SSDs, USB sticks, loop devices, RAID arrays) move fixed-size
blocks at a time, can seek arbitrarily, and can be cached by the kernel's page cache.
Character devices (terminals, serial ports, audio, /dev/null, /dev/random) are
byte streams. On modern systems /dev is itself a devtmpfs automatically populated
by the kernel as devices are discovered, with udev applying naming rules and
permissions on top.