mkdir command

mkdir command
This command creates new directory if directory already exists then displays error.
In this post, we will teach you about how to create a directory And we will discuss about other important feature of this command. So let's learn ... 

Syntax:
$mkdir  [options]  dir1 dir2 

1. mkdir dir1:- 
it creates a directory.
you want to create multiple directories at once, then you can do something like this 
There are three dir1,dir2,dit3 poli files created here. 

2. mkdir -p dir/dir1 :-
We discuss about it by taking an example so that it is easy for you to understand.
We are currently in a directory named contact, it means our current working directory is contact.  Four directories exist inside the current working directory:- dir , dir1, dir2, dir3 .
Now we want to create directory named subpoto inside photo directory but directory named photo itself does not exist in current working directory (contact).  The -p (--parent)option is helpful in such situations. 
With the help of this, both the photo directory and the subpoto directory inside it are created. 
You can see it on the screen below.















Even if the photo directory existed, it would not give any error. 
mkdir -p photo/subphoto > We can also run it in this way
 mkdir --parent photo/subphoto

3. mkdir -v dir :- 
Using this option prints a message on the screen to inform whether the directory has been created or not.











You can see the print message in the above screen that all three directories  tech , fog and rose have been created, while the my directory is not created because it is already exiting.
I have tried to make it easy to understand by taking the Linux manual page as a reference.

If you liked this article, please help others by sharing.If there is anything incorrect in this or it needs more improvement then you can comment me in the comment box below or contact at  query.me

Comments

Popular posts from this blog

ls command

wc Command

ifconfig command