I understand that block/character device files are created programmatically (by the drivers themselves?) to facilitate communications with device drivers using standard I/O calls. But why one would create these device files from command line using mknod?

Please provide some common use cases.


Historical reasons. Originally, before devfs existed, these device files were created by hand or by a script called MAKEDEV. This is also why many drivers have a fixed device number assignment; because the device numbers had to be known so that the device files would work properly.

There aren't really any common use cases for the mknod command on modern Linux systems, though it may still be used for system recovery or for very small systems that exclude devfs.

  • Once in a blue moon, someone might need mknod while doing system repairs - if someone overwrites /dev/null with a normal file, or something like that, mknod might be used to recreate it. – godlygeek Jun 1 '15 at 19:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.