/dev directory
100%

Devices · Lesson 1

/dev directory

Learn how Linux exposes device interfaces and pseudo-devices through nodes under `/dev`.

Linux exposes many kernel device interfaces through special filesystem objects called device nodes. They normally appear under /dev, alongside useful symbolic links and communication endpoints. Opening a device node connects an application to a kernel driver rather than to bytes stored in an ordinary file.

Exploring `/dev`

List the directory without dereferencing or reading devices:

$ ls -l /dev

Entries can represent physical storage, terminals, input interfaces, logical devices, or kernel-provided pseudo-devices. Not every hardware component needs its own user-visible node, and one device can be represented through several links or interfaces.

The first character of a long listing identifies the filesystem object type. Character and block device nodes appear as c and b; later lessons examine these types and their major and minor numbers.

What happens when a program opens a device node under /dev?

Pseudo-Devices

Some nodes provide kernel services without corresponding to physical hardware. /dev/null accepts and discards written data:

$ command > /dev/null

Other familiar examples include /dev/zero, which produces zero bytes, and /dev/urandom, which provides random bytes through the kernel random subsystem. Each has specific semantics; do not infer behavior only from its filename.

What does /dev/null do with data written to it?

Dynamic Device Management

On modern Linux systems, the kernel-backed devtmpfs can populate basic device nodes as devices appear. A user-space device manager such as udev processes events, applies permissions and ownership, and creates useful symbolic links or policy-driven names. Exact responsibilities vary by system.

Stable links such as entries under /dev/disk/by-id/ or /dev/disk/by-uuid/ can be safer in configuration than detection-order names such as /dev/sda, which can change when hardware topology or discovery order changes.

Why might an administrator prefer /dev/disk/by-id/... over /dev/sda in configuration?

Interacting Safely

Standard tools can open device nodes, but that does not make arbitrary reads and writes safe. Reading can expose sensitive input or storage; writing to a disk, terminal, or firmware interface can corrupt data or disrupt users. Device-node permissions, groups, ACLs, capabilities, and service mediation restrict access for this reason.

Use read-only discovery tools first, confirm the exact node and device identity, and follow device-specific documentation. Never experiment by redirecting data into an unfamiliar /dev entry on a system you care about.

Why should you avoid writing arbitrary data to an unfamiliar device node?

Lesson complete

You finished /dev directory

You can now describe /dev as a set of live kernel-facing interfaces.

  • Distinguish device nodes from ordinary files.

  • Recognize pseudo-devices such as /dev/null.

  • Relate dynamic nodes and persistent links to device management.

  • Treat direct device access as interface-specific and potentially destructive.

Keep your learning progress

Create a free account to save this lesson and continue learning on any device.

Create a free account
Next Lesson
Back to Devices