• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • VCS
  • Interview Questions
  • Database
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

mknod Command Examples in Linux

by Deepika

“mknod” is a command-line tool in Linux used to create special files, also known as device files, that represent a device, such as a disk, a partition, a terminal, or a device connected to the system through a device driver. Special files are located in the /dev directory and act as interface points between the operating system and the physical devices.

The “mknod” command takes several arguments, including the name of the special file, the type of file (block or character), and the major and minor device numbers. The major device number identifies the device driver associated with the device, while the minor device number identifies a specific instance of the device.

There are two types of special files: block and character. Block special files represent devices that handle data in blocks, such as disks, while character special files represent devices that handle data as a stream of characters, such as terminals. The “mknod” command can be used to create either type of special file.

It’s worth noting that in modern Linux systems, special files are often created automatically by the system, and manual creation with “mknod” is rarely needed. However, it is still a useful tool for advanced users who need to create custom device files or troubleshoot issues with device files.

mknod Command Examples

1. Create a block device:

# sudo mknod path/to/device_file b major_device_number minor_device_number

2. Create a character device:

# sudo mknod path/to/device_file c major_device_number minor_device_number

3. Create a FIFO (queue) device:

# sudo mknod path/to/device_file p

4. Create a device file with default SELinux security context:

# sudo mknod -Z path/to/device_file type major_device_number minor_device_number

Filed Under: Linux

Some more articles you might also be interested in …

  1. Configuring Kdump Output Location in CentOS/RHEL 9
  2. How To Force User/Group Ownership Of Files On A Samba Share
  3. finger: User information lookup program
  4. “hg remove” Command Examples
  5. Common NFS mount options in Linux
  6. mitmdump Command Examples
  7. efibootmgr Command Examples in Linux
  8. nixos-option: Command Examples in Linux
  9. e4defrag: command not found
  10. bedtools Command Examples (A swiss-army knife of tools for genomic-analysis tasks)

You May Also Like

Primary Sidebar

Recent Posts

  • Vanilla OS 2 Released: A New Era for Linux Enthusiasts
  • mk Command Examples
  • mixxx Command Examples
  • mix Command Examples

© 2025 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright