Make directories (POSIX)


mkdir [-m mode] [-p] dir...

Runs on:

QNX Neutrino


-m mode
When creating the directory, set the permission bits of the new directory to the specified mode value.

The mode argument is a symbolic_mode string, as defined for the chmod utility. In the symbolic_mode strings, the op characters + and - are interpreted relative to the default file mode for that file type:

Add permissions to the default mode.
Delete permissions from the default mode.
Assign permissions.
Create any missing intermediate pathname components.
A pathname at which a directory is to be created.

If you specify both the -p and -m options, any intermediate directories you have created have mode u+wx.


The mkdir utility creates the directories specified by the dir operands, in the order the dir operands are specified.

To create a directory, you must have write permission on the parent directory, or be root.

Note: Not all filesystems support the creation of directories. For example, /dev/shmem (which really isn't a filesystem but looks like one) doesn't. For more information, see the Working with Filesystems chapter of the QNX Neutrino User's Guide.

The default file mode for directories is a=rwx (777), with selected permissions removed in accordance with the file mode creation mask (see the umask utility).

For intermediate pathname components created by mkdir, the mode is the default modified by u+wx so that the subdirectories can always be created regardless of the file-mode creation mask. If you want to assign different ultimate permissions for the intermediate directories, you can do so with the chmod utility.

When using -p with -m, each intermediate directory that doesn't exist is created with u+wx modes, regardless of the file mode creation mask. The specified mode applies only to the last directory specified. For example:

mkdir -p -m 777 dir/dir1/dir2

gives dir and dir1 the default permissions for intermediate directories (i.e. u+wx). The directory dir2 is given a+rwx permission.

Note: The default file-creation mask influences the behavior of mkdir.


Create a directory named /home/debbie:

mkdir /home/debbie

Exit status:

All the specified directories were created successfully, or the -p option was specified and all the specified directories now exist.
An error occurred.


If the mkdir utility is terminated by a signal, some of the specified directories may have already been created.