device types
100%

Devices · Lesson 2

device types

Learn to distinguish character and block device nodes from pipes, sockets, and regular filesystem objects.

The first character in an ls -l mode identifies an object's filesystem type. Under /dev, character and block special files are device nodes. Pipes and Unix-domain socket nodes can also appear there, but they are interprocess communication objects rather than hardware device nodes.

$ ls -l /dev/null /dev/sda /run/systemd/journal/dev-log /tmp/example-fifo
crw-rw-rw- 1 root root 1, 3 ... /dev/null
brw-rw---- 1 root disk 8, 0 ... /dev/sda
srw-rw-rw- 1 root root      ... /run/systemd/journal/dev-log
prw------- 1 user user      ... /tmp/example-fifo

Entries and permissions vary by system; the example illustrates type characters only.

Character Device Nodes

A c identifies a character device. It usually exposes a stream-oriented or device-specific interface rather than addressable fixed-size storage blocks. Examples include terminals and pseudo-devices such as /dev/null.

“Character” does not require each system call to transfer exactly one character. Applications can read or write buffers, while the driver defines blocking, framing, and control behavior.

Which first mode character identifies a character device node?

Block Device Nodes

A b identifies a block device. Block devices provide addressable storage in blocks through the kernel's block layer and can support operations such as buffered I/O, partitioning, and filesystems. Disks, partitions, and logical volumes commonly have block nodes.

A block node is not a mounted filesystem. It represents a storage device or logical region; a filesystem can be created on it and mounted separately. Writing raw data to the wrong block node can destroy partition tables, filesystems, or user data.

What does first mode character b indicate?

FIFOs and Socket Nodes

A p identifies a FIFO, also called a named pipe. It provides a named byte stream through which processes can communicate. The data is not persistently stored in the FIFO node after being consumed.

An s identifies a Unix-domain socket node. It names a local socket endpoint and can support connection-oriented or datagram communication, descriptor passing, and peer credential features. Network sockets using Internet addresses do not necessarily have filesystem nodes.

Neither a FIFO nor a Unix socket node uses device major and minor numbers to select a hardware driver.

Which statement correctly distinguishes these IPC object types?

Major and Minor Device Numbers

Character and block device nodes store a device number split into major and minor components. In a long listing they replace the ordinary file-size column:

brw-rw---- 1 root disk 8, 0 ... /dev/sda

The pair tells the kernel which registered device interface and instance the node addresses. A major number is associated with a driver or device class, while the driver interprets the minor number. Do not hard-code assumptions such as “minor zero always means the first drive”; mappings depend on the subsystem and kernel interfaces.

Display type and device numbers explicitly with:

$ stat -c 'type=%F major=%t minor=%T path=%n' /dev/null

The %t and %T values are shown in hexadecimal by GNU stat.

Which objects use major and minor numbers to identify a kernel device interface?

Lesson complete

You finished device types

You can now interpret special filesystem types without treating all of them as hardware devices.

  • Read c as character and b as block device nodes.

  • Read p as FIFO and s as Unix-domain socket node.

  • Associate major and minor numbers only with device nodes.

  • Treat raw block-device access as 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