What are exactly mknod command parameters?

I want to create a jail in chroot. So I need to do:

mknod /var/chroot/bind/dev/null c 1 3
mknod /var/chroot/bind/dev/random c 1 8

What are c, 1, 3 and 8?


3 Answers 3


mknod is creating a device file, usually to be located in the /dev branch, but not necessarily like your example shows.

The first parameter is telling which kind of device to create, here c for character device. Other choices might be b for block devices, p for fifo (pipe).

The second parameter is the major number, it identifies the driver for the kernel to use.

The third parameter is the minor number, it is passed to the driver for its internal usage.

On Linux, major/minor numbers are documented here: devices.txt

So 1 is used for the so called memory devices handled by a single driver.

3 is representing the null device which returns EOF when read and discard whatever is writen to it.

8 is representing the random device which returns random numbers.

To get more information, you might to have a look to the device manual pages, e.g.

man -s 4 null
man -s 4 random
  • The man page for null doesn't explain what 1 and 3 actually are.
    – opticyclic
    Commented Jun 15, 2018 at 5:20
  • @opticyclic They are just numbers, referred to as major and minor. The Linux man page for null tells what number to use, other OSes manual pages (like say Solaris) might not.
    – jlliagre
    Commented Jun 15, 2018 at 6:48
  • The man page says "These devices are typically created by: mknod -m 666 /dev/null c 1 3". That doesn't explain why you use 1 and 3, just that you should use 1 and 3. How does "1" identify the right driver? How is "3" used by the driver internally? What does "3" represent internally? en.wikipedia.org/wiki/Magic_number_(programming)
    – opticyclic
    Commented Jun 16, 2018 at 0:37
  • 1
    Ah, I thought you were telling I wrote the manual explained these number. It is not indeed. Answer updated with a pointer to the right source of information about these numbers.
    – jlliagre
    Commented Jun 16, 2018 at 3:19

MAKEDEV is the preferred way of creating device files which are not present. However sometimes the MAKEDEV script will not know about the device file you wish to create. This is where the mknod command comes in. In order to use mknod you need to know the major and minor node numbers for the device you wish to create.

mknod /dev/ttyS0 c 4 64


Good to know:

To get the major/minor numbers of a connected device you can cat the device data:

cat /sys/class/tty/ttyUSB0/uevent



with this information you can then call: mknod /dev/ttyUSB0 c 188 0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .