Block Devices vs Character Devices in Linux

In Linux, hardware components are exposed to user space as special files located inside the /dev directory. This article provides a clear comparison between the two primary categories of device nodes: block devices and character devices. You will learn how each type handles data transmission, how the kernel buffers and accesses them, common real-world examples of both, and how to identify them using standard Linux commands.

The Role of the /dev Directory

Linux follows the Unix philosophy that "everything is a file." To allow programs to communicate with physical hardware or virtual resources, the kernel exposes these components as special files called device nodes or device files inside the /dev directory.

Instead of containing readable text or binary application data, a device file acts as an interface or endpoint to a device driver within the Linux kernel. Device files are categorized mainly into character devices and block devices based on how the operating system handles data transfers to and from them.


What Is a Character Device?

A character device (often called a "char device") communicates by sending or receiving data sequentially as a stream of individual bytes or characters.

Key attributes of character devices include:

Common Examples of Character Devices


What Is a Block Device?

A block device transfers data in fixed-size chunks known as blocks (typically 512 bytes to 4096 bytes).

Key attributes of block devices include:

Common Examples of Block Devices


Key Differences at a Glance

Feature Character Device Block Device
Data Unit Single bytes (stream) Fixed-size blocks (e.g., 512B, 4KB)
Access Pattern Sequential Random (seekable)
Buffering Unbuffered Buffered by the kernel cache
Filesystem Support Cannot host filesystems Can host mountable filesystems
Primary Use Input/output hardware, terminals Persistent storage drives

How to Identify Device Types in Linux

You can check whether a device is a block or character device using the ls -l command on any file in /dev. Look at the very first character of the file permissions string:

Example: Inspecting a Character Device

$ ls -l /dev/null
crw-rw-rw- 1 root root 1, 3 Oct 24 10:00 /dev/null

The leading c signifies that /dev/null is a character device. The numbers 1, 3 are the major and minor numbers used by the kernel to identify the corresponding driver.

Example: Inspecting a Block Device

$ ls -l /dev/sda
brw-rw---- 1 root disk 8, 0 Oct 24 10:00 /dev/sda

The leading b indicates that /dev/sda is a block device, managed by the storage driver identified by major number 8.