Make directories (POSIX)
mkdir [-m mode] [-p] dir...
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:
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.
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.
|The default file-creation mask influences the behavior of mkdir.|
Create a directory named /home/debbie:
If the mkdir utility is terminated by a signal, some of the specified directories may have already been created.
chmod, rmdir, umask