Linux and Unix mkdir command tutorial with examples

mkdir stands for make directory.
In the UNIX file system, we can create a new directory by using mkdir command.

Syntax:

Note: In above syntax in the place of [directory name] we will specify the name of directory to be created.

Example:

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.

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.

Note: The order of specifying argument important because we can not create subdirectory without creating its parent directory. For example we can not write

Command mkdir failed to create two subdirectories abc1 and abc2 but it will create directory acb.

Read More

Linux and Unix printf command tutorial with examples

Linux and Unix cat command tutorial with examples