mknod
Create device files (special files)
TLDR
Create a block device
Create a character device
Create a FIFO (queue) device
Create a device file with default SELinux security context
SYNOPSIS
mknod NAME TYPE [MAJOR MINOR]
PARAMETERS
NAME
The name of the special file to create.
TYPE
The type of special file to create. It must be either 'b' (block special file) or 'c' (character special file).
MAJOR
The major device number. This identifies the device driver.
MINOR
The minor device number. This identifies a specific device instance.
DESCRIPTION
The mknod command is used to create a special file system object, specifically a character special file or a block special file. These special files represent device drivers that allow user-space programs to interact with hardware devices. Character devices transfer data one character at a time, while block devices transfer data in blocks. The mknod command requires root privileges to create these special files, as they directly affect the system's hardware interface.
The first argument determines the file name to create. The second argument specifies the type of the file, either 'b' for block special file or 'c' for character special file.
The final two arguments provide the major and minor device numbers, which identify the specific device driver associated with the special file. The major number identifies the driver itself, while the minor number distinguishes individual instances of the device.
CAVEATS
Requires root privileges to execute successfully. Improper use can lead to system instability.
EXAMPLE
To create a character special file named 'ttyUSB0' with major number 188 and minor number 0, use the following command:sudo mknod /dev/ttyUSB0 c 188 0
HISTORY
The mknod command is a fundamental utility in Unix-like operating systems, originating from the early days of Unix. Its purpose has remained consistent: to allow the creation of special files representing device drivers. It's essential for managing hardware interaction within the operating system. Over time, its implementation has been refined, but its core functionality has remained the same.