man mknod on Linux:
c, u create a character (unbuffered) special file
Why are there 2 letters for the same function? Is there any subtle difference, or they are completely alike?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
They're identical, at least on Linux.
I came to this conclusion by first looking at the source code for
mknod(1) in the GNU coreutils, where on line 217 in the current version we find that the
'u' cases are treated identically, getting the same device type. The
S_IFCHR value is defined in the Linux kernel headers, but the value is not important. All that matters is that the same value gets stored in the filesystem's dev node.
I clinched the issue with a simple test:
$ sudo mknod /dev/null2 u 1 3 $ ls -l /dev/null* crw-rw-rw- 1 root root 1, 3 Jan 12 2015 /dev/null crw-r--r-- 1 root root 1, 3 Oct 19 22:56 /dev/null2
u in the command gives the same dev node as
c. Case closed.
As to why both characters are allowed, my best guess is that it's just an alias for those who think of
b as meaning "buffered" rather than "block," so that you need
u as its opposite, meaning "unbuffered," rather than
c for "character."
I originally thought that this feature of GNU
mknod might have been for compatibility with some pre-Linux flavor of Unix, since
mknod in GNU Fileutils predates Linux itself,¹ and this feature of GNU
mknod goes clear back to the very first version-controlled checkin of
mknod.c, but I have yet to find documentation for any Unix that will accept
u as an argument to
mknod(1), so that hypothesis doesn't hold water.²
mknod utility was added to GNU Fileutils in July 1991. The first version of the Linux kernel wasn't posted to Usenet until September 1991. That tells us that the first version of GNU
mknod must have supported non-Linux OSes from the start.
You will find
mknod u documented for other OSes — such as Minix 3 — but only because they're also using the GNU Coreutils implementation of
mknod(1). Another oddity is modern Solaris, which ships both AT&T
mknod and GNU
mknod, documented separately in manual sections 1m (linked above) and in section 1g, respectively.