mkdir (Make Directory)
![Creating Directories with mkdir Command](/_next/image/?url=https%3A%2F%2Fstatic.d-libro.com%2F01-course-content-images%2F2011-10-Linux-Introduction%2F010-main-figures%2Fmkdir-make-directory-id201110020510.webp&w=1920&q=75)
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