• 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. retroarch: command not found
  2. calcurse: command not found
  3. gatsby: Static site generator for React
  4. “git remote” Command Examples
  5. cgcreate: command not found
  6. firejail: command not found
  7. Understanding multipath Utility to Configure DM-Multipath
  8. arp: command not found
  9. How To Force User/Group Ownership Of Files On A Samba Share
  10. lvextend command examples in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • glab Command Examples
  • “glab repo” Command Examples
  • “glab release” Command Examples
  • “glab pipeline” Command Examples

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright