mkdir (host)
Make directories (POSIX)
Syntax:
mkdir [-m mode] [-p] dir...
Runs on:
Microsoft Windows
Options:
- -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.
- -p
- Create any missing intermediate pathname components.
- dir
- 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
.
Description:
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.
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 you use -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.
Examples:
Create a directory named /home/debbie:
mkdir /home/debbie
Exit status:
- 0
- All the specified directories were created successfully, or the -p option was specified and all the specified directories now exist.
- >0
- An error occurred.
Caveats:
If the mkdir utility is terminated by a signal, some of the specified directories may have already been created.