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 mode Set permission mode (as in chmod), not rwxrwxrwx - umask.
-p No error if existing, make parent directories as needed.
-v Print a message for each created directory
-Z (SELinux) set security context to CONTEXT
directory The 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