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

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • 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. CentOS / RHEL 6 : How to Disable / Enable direct root login via telnet
  2. How to recover deleted Logical volume (LV) in LVM using vgcfgrestore
  3. mv: command not found
  4. How to change hostname in CentOS/RHEL 7
  5. dnsrecon: command not found
  6. certbot: command not found
  7. How to Use the ssh-keygen Command to configure passwordless ssh
  8. How to Compress and Extract Files and Directories in Linux Using gzip and bzip2
  9. LVM Commands Fail With “Failed to load config file /etc/lvm/lvm.conf”
  10. How to Install Apache, MariaDB, and PHP (FAMP) stack on FreeBSD 11

You May Also Like

Primary Sidebar

Recent Posts

  • protonvpn-cli Command Examples in Linux
  • protonvpn-cli connect Command Examples
  • procs Command Examples in Linux
  • prlimit: command not found

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright