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 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 that the special file is a block-oriented device (disk, diskette, or tape). The c flag indicates that the special file is a character-oriented device (other devices).

The last two parameters of the first form are numbers that specify the Major device and the Minor device. The Major device number helps the operating system find the device driver code. The Minor device number is the unit drive or line number that might 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 that the special file is a block-oriented device (disk, diskette, or tape).
c Indicates that the special file is a character-oriented device (other devices).
p Creates FIFOs (named pipelines).

Security

Attention RBAC users and Trusted AIX users: This command can perform privileged operations. Only privileged users can run privileged operations. For more information about authorizations and privileges, see Privileged Command Database in Security. For a list of privileges and the authorizations that are associated with this command, see the lssecattr command or the getcmdattr subcommand.

Examples

  1. 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.

  2. To create the special file for a new character drive, enter the following command:
    mknod /dev/fc1  c 1 2

    This command creates the /dev/fc1 special file that is a special character file with the major device number 1 and the minor device number 2.

  3. To create a FIFO pipe file, enter the following command:
    mknod fifo1 p

    This command creates a FIFO pipe file that has the name fifo1.

Files

Item Description
/usr/sbin/mknod Contains the mknod command.