mkdir (Make Directory)
To create a new directory, you can use the mkdir
(MaKe DIRectory) command while specifying the directory path and including the new directory name at the end of the path.
Create a new directory with the relative path
To create a new directory named dir_a under your working directory, run the command below.
mkdir dir_a
If you want to create a new directory named dir_b under the parent directory, run the command below.
mkdir dir_b
Create a new directory with the absolute path
You can use the absolute path to create a new directory. To create dir_c under the ubuntu directory, you can run the command below.
mkdir /home/ubuntu/dir_c
-p option
If you want to create multiple directories with a tree structure, you can use the -p
option. To create three directories like dir_3 under dir_2 under dir_1 under your home directory, you can run the command below.
mkdir -p ~/dir_1/dir_2/dir_3