function::MKDEV - Linux


The mkdev command is used to create a device file, allowing access to special hardware devices in the Linux system. It is particularly useful for assigning permissions and configuring device attributes.


mkdev [OPTIONS] major minor device-file


| Option | Description |
| -m | Create a block device file instead of character device file (default). |
| -c | Create a character device file instead of block device file (default). |
| -f | Force creating the device file even if it already exists. |


Create a block device file:

mkdev -m 8 0 /dev/sdc

Create a character device file:

mkdev -c 16 64 /dev/ttyACM0

Force creating an existing character device file:

mkdev -cf 16 64 /dev/uart0

Common Issues

  • Permission denied: Ensure that the user has sufficient privileges to create device files.
  • Device file already exists: Use the -f option to overwrite existing device files.
  • Invalid major/minor numbers: Verify that the specified major and minor numbers correspond to the desired device.


mkdev can be combined with other commands to automate device configuration tasks:

mkdev 8 0 /dev/sdc && chown user:group /dev/sdc && chmod 660 /dev/sdc

Related Commands

  • mdev – Dynamically creates device files for hot-pluggable devices.
  • device-mapper – Provides a framework for managing logical block devices.
  • parted – Tool for partitioning disks and managing filesystems.