In this Blog, we will learn how we can use mkdir command in Linux.
mkdir means make directory, We can create directories in Linux.
First of all open Terminal Alt+Ctrl+t.
Syntax for mkdir command is:
mkdir [directory_name]
In above screenshot you can see that firstly I want to create a directory named as example in Desktop.So, I have used cd command and gone to Desktop directory and then mkdir command is used.
In similar way if you want to create directory anywhere, you should go to that directory and use mkdir command.
Now if you want to create sub directory of directory which is already exists, you can use command in this manner:
mkdir [1st dir name] / [sub-dir name]
You can see that example directory which is already exists now contains a sub-directory named as subdir.
If you try to use same command for the creating sub-directory of directory which doesn't even exists it will show error that can not create directory: directory does not exists.
Like this:
Now if you want to create such a parent directory and sub-directory which does not exists then we have to use one flag or say option i.e, -p
mkdir -p [parent dir name] / [sub-dir name]
Now you can see that parent directory and sub-directory is created.
In a parent directory if you want to create several sub-directories then we can use command as:
mkdir -p [parent dir name] / {sub-dir1,sub-dir2,sub-dir3.....}
Remember one thing that while giving names of sub-directories do not give space in between two sub-directories name.
In this way you can able to use mkdir command in Linux.
For any query and suggestions you may contact with me or you may put comment in comment box.
Thank You.
Contact Details:
Phone: +91-8208826234
E-mail: shivampawar1038@gmail.com
mkdir means make directory, We can create directories in Linux.
First of all open Terminal Alt+Ctrl+t.
Syntax for mkdir command is:
mkdir [directory_name]
In above screenshot you can see that firstly I want to create a directory named as example in Desktop.So, I have used cd command and gone to Desktop directory and then mkdir command is used.
In similar way if you want to create directory anywhere, you should go to that directory and use mkdir command.
Now if you want to create sub directory of directory which is already exists, you can use command in this manner:
mkdir [1st dir name] / [sub-dir name]
You can see that example directory which is already exists now contains a sub-directory named as subdir.
If you try to use same command for the creating sub-directory of directory which doesn't even exists it will show error that can not create directory: directory does not exists.
Like this:
Now if you want to create such a parent directory and sub-directory which does not exists then we have to use one flag or say option i.e, -p
mkdir -p [parent dir name] / [sub-dir name]
Now you can see that parent directory and sub-directory is created.
In a parent directory if you want to create several sub-directories then we can use command as:
mkdir -p [parent dir name] / {sub-dir1,sub-dir2,sub-dir3.....}
Remember one thing that while giving names of sub-directories do not give space in between two sub-directories name.
In this way you can able to use mkdir command in Linux.
For any query and suggestions you may contact with me or you may put comment in comment box.
Thank You.
Contact Details:
Phone: +91-8208826234
E-mail: shivampawar1038@gmail.com
Gud going brother..
ReplyDeleteThank You
DeleteImages help alot.Nice 1
ReplyDeleteThank You.
Delete