mknod: command not found

“mknod” is a command-line tool in Linux used to create special files, also known as device files, that represent a device, such as a disk, a partition, a terminal, or a device connected to the system through a device driver. Special files are located in the /dev directory and act as interface points between the operating system and the physical devices.

The “mknod” command takes several arguments, including the name of the special file, the type of file (block or character), and the major and minor device numbers. The major device number identifies the device driver associated with the device, while the minor device number identifies a specific instance of the device.

There are two types of special files: block and character. Block special files represent devices that handle data in blocks, such as disks, while character special files represent devices that handle data as a stream of characters, such as terminals. The “mknod” command can be used to create either type of special file.

It’s worth noting that in modern Linux systems, special files are often created automatically by the system, and manual creation with “mknod” is rarely needed. However, it is still a useful tool for advanced users who need to create custom device files or troubleshoot issues with device files.

If you encounter the below error while running the command mknod:

mknod: command not found

you may try installing the below package as per your choice of distribution:

Distribution Command
Debian apt-get install coreutils
Ubuntu apt-get install coreutils
Alpine apk add coreutils
Arch Linux pacman -S coreutils
Kali Linux apt-get install coreutils
CentOS yum install coreutils
Fedora dnf install coreutils
OS X brew install coreutils
Raspbian apt-get install coreutils

mknod Command Examples

1. Create a block device:

# sudo mknod path/to/device_file b major_device_number minor_device_number

2. Create a character device:

# sudo mknod path/to/device_file c major_device_number minor_device_number

3. Create a FIFO (queue) device:

# sudo mknod path/to/device_file p

4. Create a device file with default SELinux security context:

# sudo mknod -Z path/to/device_file type major_device_number minor_device_number
Related Post