Section (1) mknod
mknod — make block or character special files
Create the special file NAME of the given TYPE.
Mandatory arguments to long options are mandatory for short options too.
set file permission bits to MODE, not a=rw − umask
set the SELinux security context to default type
−Z, or if CTX is specified then set the SELinux or SMACK security context to CTX
display this help and exit
output version information and exit
Both MAJOR and MINOR must be specified when TYPE is b, c, or u, and they must be omitted when TYPE is p. If MAJOR or MINOR begins with 0x or 0X, it is interpreted as hexadecimal; otherwise, if it begins with 0, as octal; otherwise, as decimal. TYPE may be:
create a block (buffered) special file
- c, u
create a character (unbuffered) special file
create a FIFO
Your shell may have its own version of mknod, which usually supersedes the version described here. Please refer to your shell_zsingle_quotesz_s documentation for details about the options it supports.
GNU coreutils online help: <https://www.gnu.org/software/coreutils/>
Report any translation bugs to <https://translationproject.org/team/>
Full documentation <https://www.gnu.org/software/coreutils/mknod>
or available locally via: info _zsingle_quotesz_(coreutils) mknod invocation_zsingle_quotesz_
Copyright © 2019 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
Section (2) mknod
mknod, mknodat — create a special or ordinary file
#include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <unistd.h>
||const char *pathname,|
#include <fcntl.h> /* Definition of AT_* constants */ #include <sys/stat.h>
|const char *pathname,|
The system call
creates a filesystem node (file, device special file, or
named pipe) named
pathname, with attributes
specifies both the file mode to use and the type of node to
be created. It should be a combination (using bitwise OR) of
one of the file types listed below and zero or more of the
file mode bits listed in inode(7).
The file mode is modified by the process_zsingle_quotesz_s
umask in the usual way: in the absence of a
default ACL, the permissions of the created node are
The file type must be one of
S_IFSOCK to specify a regular file (which
will be created empty), character special file, block special
file, FIFO (named pipe), or UNIX domain socket, respectively.
(Zero file type is equivalent to type
If the file type is
dev specifies the major and
minor numbers of the newly created device special file
(makedev(3) may be useful to
build the value for
dev); otherwise it is
already exists, or is a symbolic link, this call fails with
an EEXIST error.
The newly created node will be owned by the effective user ID of the process. If the directory containing the node has the set-group-ID bit set, or if the filesystem is mounted with BSD group semantics, the new node will inherit the group ownership from its parent directory; otherwise it will be owned by the effective group ID of the process.
mknodat() system call
operates in exactly the same way as
mknod(), except for the differences
If the pathname given in
pathname is relative, then it
is interpreted relative to the directory referred to by the
dirfd (rather than relative
to the current working directory of the calling process, as
is done by
mknod() for a
is the special value
pathname is interpreted
relative to the current working directory of the calling
dirfd is ignored.
See openat(2) for an
explanation of the need for
mknodat() return zero on success, or
−1 if an error occurred (in which case,
errno is set appropriately).
The parent directory does not allow write permission to the process, or one of the directories in the path prefix of
pathnamedid not allow search permission. (See also path_resolution(7).)
The user_zsingle_quotesz_s quota of disk blocks or inodes on the filesystem has been exhausted.
pathnamealready exists. This includes the case where
pathnameis a symbolic link, dangling or not.
pathnamepoints outside your accessible address space.
moderequested creation of something other than a regular file, device special file, FIFO or socket.
Too many symbolic links were encountered in resolving
pathnamewas too long.
A directory component in
pathnamedoes not exist or is a dangling symbolic link.
Insufficient kernel memory was available.
The device containing
pathnamehas no room for the new node.
A component used as a directory in
pathnameis not, in fact, a directory.
moderequested creation of something other than a regular file, FIFO (named pipe), or UNIX domain socket, and the caller is not privileged (Linux: does not have the
CAP_MKNODcapability); also returned if the filesystem containing
pathnamedoes not support the type of node requested.
pathnamerefers to a file on a read-only filesystem.
The following additional errors can occur for
dirfdis not a valid file descriptor.
pathnameis relative and
dirfdis a file descriptor referring to a file other than a directory.
mknodat() was added to Linux
in kernel 2.6.16; library support was added to glibc in
mknod(): SVr4, 4.4BSD,
POSIX.1-2001 (but see below), POSIX.1-2008.
POSIX.1-2001 says: The only portable use of
mknod() is to create a FIFO-special file.
mode is not
dev is not 0, the behavior of
mknod() is unspecified.
However, nowadays one should never use
mknod() for this purpose; one should use
mkfifo(3), a function
especially defined for this purpose.
be used to create directories. One should make directories
There are many infelicities in the protocol underlying
NFS. Some of these affect
This page is part of release 4.16 of the Linux
man-pages project. A
description of the project, information about reporting bugs,
and the latest version of this page, can be found at
This manpage is Copyright (C) 1992 Drew Eckhardt;
and Copyright (C) 1993 Michael Haardt
and Copyright (C) 1993,1994 Ian Jackson
and Copyright (C) 2006, 2014, Michael Kerrisk
You may distribute it under the terms of the GNU General
Public License. It comes with NO WARRANTY.
Modified 1996-08-18 by urs
Modified 2003-04-23 by Michael Kerrisk
Modified 2004-06-23 by Michael Kerrisk <mtk.manpagesgmail.com>