Block vs Character Devices
In Linux, everything is a file — including hardware. Hard drives, keyboards, random number generators, terminals — all appear as files in /dev/. But not all device files are the same: block devices and character devices behave very differently.
Block Devices — Random Access Storage
Block devices store data in fixed-size blocks and support random access — you can read or write any block directly:
- Hard drives: /dev/sda, /dev/sdb (SATA)
- NVMe SSDs: /dev/nvme0n1, /dev/nvme1n1
- Partitions: /dev/sda1, /dev/nvme0n1p1
- Virtual disks: /dev/vda (in VMs)
- Loop devices: /dev/loop0 (mount ISO files)
Character Devices — Sequential Stream
Character devices provide a stream of bytes, accessed sequentially (no seeking back):
- /dev/null: Discards anything written. Reads return EOF.
- /dev/zero: Reads return infinite null bytes.
- /dev/random, /dev/urandom: Random bytes from kernel entropy pool.
- /dev/tty: Your controlling terminal.
- /dev/pts/0: Pseudo-terminal (SSH sessions, terminal emulators).
- /dev/input/event0: Keyboard or mouse input events.
Major and Minor Numbers
Practical Uses
Frequently Asked Questions
What will I learn here?
This page covers the core concepts and techniques you need to understand the topic and progress confidently to the next lesson.
How should I use this page?
Start with the overview, then follow the section links to deepen your understanding. Use the table of contents on the right to jump to specific sections.
What should I read next?
Use the navigation below to continue to the next lesson or explore related topics.