Devices · Lesson 2 of 7
device types
0%
0 / 4 checkpoints answered
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.
CheckWhich first mode character identifies a character device node?
press 1/2/3 to answer · → next lesson
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.
CheckWhat does first mode character b indicate?
press 1/2/3 to answer · → next lesson
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.
CheckWhich statement correctly distinguishes these IPC object types?
press 1/2/3 to answer · → next lesson
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.
CheckWhich objects use major and minor numbers to identify a kernel device interface?
press 1/2/3 to answer · → next lesson
Summary
You can now interpret special filesystem types without treating all of them as hardware devices.
- Read
cas character andbas block device nodes. - Read
pas FIFO andsas Unix-domain socket node. - Associate major and minor numbers only with device nodes.
- Treat raw block-device access as potentially destructive.
Practice
In the practice terminal, run: stat -c 'type=%F major=%t minor=%T path=%n' /dev/null It should print type=character special file along with major and minor device numbers.
stat -c lets you choose which fields to print.
Lesson complete
You finished device types. Nice work — keep the momentum going.