You are here: >

Linux and Unix mkdir command

mkdir commandAbout mkdir
mkdir syntax
mkdir examples
Related commands
Linux and Unix main page

About mkdir

Short for "make directory", mkdir is used to create directories on a file system.


If the specified DIRECTORY does not already exist, mkdir creates it.

More than one DIRECTORY may be specified when calling mkdir.

mkdir syntax

mkdir [OPTION ...] DIRECTORY ...


-m, --mode=MODE Set file mode (as with the chmod command).
-p, --parents Create parent directories as necessary. When this option is used, no error is reported if a specified DIRECTORY already exists.
-v, --verbose Verbose output; print a message for each created directory.
-Z, --context=CTX Set the SELinux security context of each created directory to the context CTX.
--help Display a help message, and exit.
--version Display version information, and exit.

mkdir examples

mkdir mydir

Creates a new directory called mydir whose parent is the current directory.

mkdir -m a=rwx mydir

Create the mydir directory, and set its permissions such that all users may read, write, and execute the contents.

mkdir -p /home/chope/a/b/c

Creates the directory /home/chope/a/b/c. If the parent directory /home/chope/a/b does not already exist, mkdir will create that directory first.

rmdir — Remove a directory.