Glossary

Device File

A device file is a special file in /dev that user-space programs use to interact with hardware or virtual devices. Reads and writes are translated by the kernel into calls to the appropriate driver. Device files come in two flavours: character devices (like /dev/tty, which handles data one character at a time) and block devices (like /dev/sda, which handles fixed-size blocks of data).

A device file is identified by its major number (selecting the driver) and minor number (selecting the specific device within that driver), visible with ls -l:

crw--w---- 1 root tty     4, 1 /dev/tty1       # character, major 4, minor 1
brw-rw---- 1 root disk    8, 0 /dev/sda        # block, major 8, minor 0

On modern Linux, device files are created automatically by devtmpfs and udev, rather than by a static mknod at install time. udev rules can assign symlinks, group membership, and permissions based on device attributes, so that plugging in a specific USB stick always creates a predictable /dev/my-backup symlink to whatever /dev/sdX1 the kernel happens to assign.

The "everything is a file" philosophy of Unix makes device files powerful: standard tools like dd, cat, and cp can operate directly on devices, for tasks ranging from disk imaging to raw serial communication.

Related terms: /dev, /dev/null

Discussed in:

Also defined in: Textbook of Linux