mknodx
Make block or character special files, or named pipes.
Mirrors GNU mknod. Run it as mknodx, or as gnux mknodx.
Synopsis
mknodx [OPTION]... NAME TYPE [MAJOR MINOR]GNU reference
Description
mknodx creates the special file NAME of TYPE: b for a block device, c (or u) for a character device, both with their MAJOR and MINOR device numbers, or p for a named pipe, which takes none. Only TYPE's first letter counts, so 'character' works. Device numbers are decimal, octal with a leading 0, or hexadecimal with 0x. The file is readable and writable by everyone, less the umask; -m MODE sets its permissions exactly, octal or symbolic as chmod takes it, applied to a=rw (only the permission bits). Creating a device file normally needs root. -Z and --context are accepted and ignored, as by GNU mknod on a kernel without SELinux. Windows has no special files, so there every TYPE fails with 'Operation not supported'.
Permissions
Needs write and search permission on the directory, and for a device file the privilege to create one (root, or CAP_MKNOD on Linux).
Use cases
- Recreating a missing /dev entry in a chroot, container image or rescue system.
- Creating a named pipe where only
mknodis at hand in a script.
Flags
-Z, --context CTX[=" "] set the SELinux security context to default type, or to CTX (ignored: gnux does not support SELinux)
--help display this help and exit
-m, --mode MODE set file permission bits to MODE, not a=rw - umask
--version output version information and exitExamples
Recreate /dev/null in a chroot (Linux, as root)
mknodx -m 666 /srv/chroot/dev/null c 1 3Make a named pipe, as mkfifox does
mknodx jobs.fifo pCreate a loop device node (Linux, as root)
mknodx -m 660 /dev/loop8 b 7 8Options
Each option has a page of its own, with its usage and examples.
- -Z, --context: Set the SELinux security context to default type, or to CTX (ignored:
gnuxdoes not support SELinux). - -m, --mode: Set file permission bits to MODE, not a=rw - umask.
Exit status
| Status | Meaning |
|---|---|
| 0 | success: every operand was processed |
| 1 | failure: an operand could not be processed (diagnosed on standard error), or a command-line mistake |
Help in the terminal
mknodx --help # options, first examples, exit status
gnux help mknodx # this page: the full manual
gnux help mknodx --OPTION # one option in depth, with its examples