mkdir Command – UNIX

mkdir Command UNIX


mkdir is short of make directory.

As name suggests mkdir command is used to create directory.


Following options can be used with the mkdir command:

-m, –mode=MODE no error if existing, make parent directories as needed
-p, –parents do not list implied “.” and “..”
-v, –verbose print a message for each created directory
-Z, –context=CTX set the SELinux security context of each created directory to CTX
–help display this help and exit
–version output version information and exit


Example 1:

To create multiple directories.

$ mkdir epw_1 epw_2

$ ls -lrt
total 12
drwxr-xr-x 2 root root 4096 May 10 08:26 epw_2
drwxr-xr-x 2 root root 4096 May 10 08:26 epw_1

Example 2:

Creating a directory, if the parent directory does not exists

$ mkdir -p epw/sub_epw/sub_epw1