Linux and Unix mkdir command

Quick links

About mkdir
Syntax
Examples
Related commands
Linux and Unix main page

About mkdir

Short for make directory this command is used to create a new directory.

Syntax

mkdir [option] directory

-m modeSet permission mode (as in chmod), not rwxrwxrwx - umask.
-pNo error if existing, make parent directories as needed.
-vPrint a message for each created directory
-Z(SELinux) set security context to CONTEXT
directoryThe name of the directory that you wish to create.

Examples

mkdir mydir

The above command creates a new directory called mydir.

mkdir -m a=rwx mydir

This next example would use the -m option to not only create the mydir directory but also set the permissions to all users having read, write, and execute permissions.

Related commands

rmdir