I just started using Ubuntu as my main OS and I wanted to learn about things I should not do, and learn by the bad things people have done in the past. I came across these email about horror stories that UNIX & Linux sys admins had done on their own system when they where new. Many of them involved the use of the mknod command to both distory and fix a problem. I've never heard of this command before and the man page within Ubuntu is not very helpful. So my question is, what is this command used for, and what are some examples where it is useful in day to day use?


5 Answers 5


mknod was originally used to create the character and block devices that populate /dev/. Nowadays software like udev automatically creates and removes device nodes on the virtual filesystem when the corresponding hardware is detected by the kernel, but originally /dev was just a directory in / that was populated during install.

So yes, in case of a near complete disaster causing the /dev virtual filesystem not to load and/or udev failing spectacularly, using mknod to painstakingly repopulate at least a rudimentary device tree to get something back up can be done... But yeah, that's sysadmin horror story time. Personally, I recommend a rescue USB stick or CD.

Aside from creating named pipes, I can't think of a single possible day-to-day use for it that an end user would need to concern themselves with -- and even that is stretching the definition of 'day to day use'.

  • So it's a VERY specialized way of creating a virtual file that is really used by devices connected to the system as a way of communicating with the system without having to learn how to communicate with the device through it's driver? Apr 6, 2011 at 7:52
  • 1
    But udev is Linux-specific, is it not? Perhaps other Unix-like systems still manually create devices? Apr 6, 2011 at 8:05
  • 3
    @mark Er, no. Creating virtual device files is how software is supposed to communicate with the device through its driver. The driver creates the hook in the kernel; mknod creates the device file that links the hook to a device file that software subsequently can connect to. Apr 6, 2011 at 8:23
  • @Faheem I'm not sure; FreeBSD seems to use devfs and/or devd but I have no personal experience with either. I suspect other unices have worked out their own ways to automate the process of making device nodes though. Apr 6, 2011 at 8:25
  • @mark For example, Alsa generates a series of nodes in /dev/snd corresponding to the various elements of each bit of sound hardware it detected and supports. Software that uses sound can use those devices to generate sound without having to know precisely what kind of sound card they're talking to. Apr 6, 2011 at 8:29

You can make a named pipe with it.

I use it with one program to read from it, and another one to write into it.

Makes it easier to communicate between processes.

Otherwise, you may create device files, for devices that aren't present.

Also: http://publib.boulder.ibm.com/infocenter/aix/v6r1/index.jsp?topic=/com.ibm.aix.cmds/doc/aixcmds3/mknod.htm

  • While you answer was correct, Shadur provided an answer that was clear for all levels of readers so I feel it's the best for people looking for an answer for this question. Apr 8, 2011 at 10:10
  • I know, I just tried to explain from a practical approach as I do it. Using mknod for something else than making named pipes is more than rare.
    – polemon
    Apr 10, 2011 at 5:15

As oracle DBAs working on raw devices to create Oracle ASM diskgroups, we regularly use mknod to link devices.

The replies above were very helpful to me as we are not system admins. I just wanted to point out that it might be rare from storage admins' point of view to use mknod but from Oracle ASM point of view its a common use. (May be someone could come up with a better way for us?)

  • 1
    I'm running ASM on Linux and haven't had any reason to run mknod. I have some udev scripts that make symlinks, but not sure what you need mknod for... Unless you're not on Linux. of course.
    – derobert
    Oct 1, 2012 at 15:56
  • 1
    @JayJee Be advised that on modern Linux systems, if you make changes or additions to /dev with mknod, those changes will go away the next time the system is rebooted. You would need to write a script or an udev rule file that would make the changes/additions for you at boot time to make them persistent.
    – telcoM
    Sep 28, 2019 at 14:43

IMHO, even for making named pipes, the mkfifo command be better than mknod. One, it's self descriptive in it's name, Second, it permits -m option to override umask settings.

  • 2
    ...and it didn't exist until a decade after named pipes; a lot of us learned mknod foo p when it was the only way.
    – user41515
    May 11, 2014 at 4:21
  • I had never even heard of mknod until recently when I was looking through coreutils. I've always just used mkfifo...
    – Six
    Mar 28, 2015 at 19:38

The command “mknod” was released to licensees in Unix(tm) Version 4 by AT&T. I would recommend to y’all that it’s worthwhile to spend the time and money to get a copy of

Bell System Technical Journal, 57: 6. July-August 1978 pp 1905-1929. The UNIX Time-Sharing System. (Ritchie, D.M.; Thompson, K.)

That issue, and especially that article, will lead you to an appreciation of several fundamental concepts that allow the construction of the elegant, compact, fast, stable, secure, and versatile operating system that Unix(tm)) was. The various systems that are now available are still quite versatile ;-)

I’ll try to mention a few of those here.

1) the setuid and setgid bits and how the use of said bits allow separation of users into trusted and untrusted privilege domains. Hop springs eternal that trusted users will be less likely to command the system to “ # cd /; rm -rf * .o” , notice both th improper use of privilege and the “space of destruction.” Notice also that th end of a sentence with a quoted phrase dictates the order of the full-stop and the closing quotation mark. English grammar sucks(fm). dmr and ken donated the semnal patent to the public, bless them.

2) device access through the same namespace as files. Here is where the simple elegance of a small tool combined with other simple tools to perform activities not thought of by the founders becomes powerful.

3) A file in data space is a string. Structure is imposed by programs in program space and not tightly bound to s complicated Swiss-Army-Knife program. Apple(R), Microsoft(R), and IBM(R) might have had better products had more of them read BSTJ.

4) stdin, stdout, stderr.

5) shells, interpretive command processors, able to easily com ine simple tools.

6) only optimize code in inner loops, spend your limited time and money where it counts.

7) don’t embed i/o syntax in language translation processors.


8) KISS.

9) “It’s easier to design ans implement a multi-user timesharing ayaeem system extension to a good real-time system than the other way ‘round,” me, A timesharing extension to RSX-11D, implemented using small tools, written in MACRO 11 when unavoidat, otherwise higher level languages pr script was pretty good, 16 users on a 248k byte PDP-11//45 (16k solid state memory the rest core). Concurrent program development with FOCAL, BASIC, FORTRAN IV, C, MACRO-11, link editing, program execution, batch, interactive, and control/data acquisition of multiple scientific experiments using a LAB-11 and creative customized interfaces to A/D, D/A, high resolution clocks, ...

No observable irritating delay editing with 9600baud CRTs or 120cps printers 30cps DECwriters. A bit jerky staccato with a 300 lpm printer. UT200 and 2780 for RJE. Fastesr program development than RSX-11M, RSX-11M+, IAS,and early versions of VMS.

A really simple time-sharing scheduler implemented as a real-time task using the happy characteristics of a priority linked ATL implemented as a dequeue.

Unix varieties are lightning fast nowadays, but only because CPUs can do an infinite loop in three seconds. TFC.

  • Please excuse me typing mistakes. iPhone and Parkinson’s don’t play well together. C<FORTRAN<COBOL<PL/1, leftis better.
    – k6mrm
    Sep 28, 2019 at 7:33
  • None of this actually addresses the question asked.
    – JdeBP
    Jan 16, 2020 at 0:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .