mkdir stands for make directory.
In the UNIX file system, we can create a new directory by using mkdir command.
$ mkdir [directory name]
Note: In above syntax in the place of [directory name] we will specify the name of directory to be created.
$ mkdir abc [press enter]
The directory abc is created. To confirm directory is created press “ls” command which prints the name of all files and directory along with directory “abc” in the current directory.
Create multiple directory: We can create multiple directory with mkdir. Suppose we want to create 3 directory abc1, abc2 and abc3 then the command to create three directories as shown below.
$ mkdir abc1 abc2 abc3 [press enter]
Create subdirectory: We can create directory inside another directory by using single invocation of command.
Suppose we want to create directory abc and subdirectory abc1 and abc2 inside the directory abc then the command is as follows.
$ mkdir abc abc/abc2 abc/abc2 [press enter]
Note: The order of specifying argument important because we can not create subdirectory without creating its parent directory. For example we can not write
$ mkdir abc/abc2 abc/abc2 abc [press enter]
mkdir: failed to make directory ”abc/abc1”; No such file or directory
mkdir: failed to make directory ”abc/abc2”; No such file or directory
Command mkdir failed to create two subdirectory abc1 and abc2 but it will create directory acb.