mknod Command
Purpose
Creates a special file.
Syntax
Only executed by root or system group member
mknod Name { b | c } Major Minor
Creates FIFO (first-in, first-out) files, which are also called pipes or pipelines
mknod Name { p }
Description
The mknod command makes a directory entry and corresponding i-node for a special file. The first parameter is the name of the entry device. Select a name that is descriptive of the device. The mknod command has two forms that have different flags.
The first form of the mknod command can only be executed by root or a member of the system group. In the first form, the b or c flag is used. The b flag indicates the special file is a block-oriented device (disk, diskette, or tape). The c flag indicates the special file is a character-oriented device (other devices).
The last two parameters of the first form are numbers specifying the Major device, which helps the operating system find the device driver code, and the Minor device, that is the unit drive or line number, which may be either decimal or octal. The major and minor numbers for a device are assigned by the device's configure method and are kept in the CuDvDr class in ODM.
It is important that the major and minor numbers be defined in this object class to ensure consistency of device definitions through the system.
In the second form of the mknod command, the p flag is used to create FIFO pipelines.
Flags
Item | Description |
---|---|
b | Indicates the special file is a block-oriented device (disk, diskette, or tape). |
c | Indicates the special file is a character-oriented device (other devices). |
p | Creates FIFOs (named pipelines). |
Security
Examples
- To create the special file for a new diskette drive, enter the following
command:mknod /dev/fd2 b 1 2
This command creates the /dev/fd2 special file that is a special block file with the major device number 1 and the minor device number 2.
- To create the special file for a new character drive, enter the following
command:
This command creates themknod /dev/fc1 b 1 2
/dev/fc1
special file that is a special character file with the major device number 1 and the minor device number 2. - To create a FIFO pipe file, enter the following
command:
This command creates a FIFO pipe file that has the name fifo1.mknod fifo1 p
Files
Item | Description |
---|---|
/usr/sbin/mknod | Contains the mknod command. |