This article gives a complete and deep knowledge of How to work with the directories in Linux in a very simple and easy language with examples
mkdir command
mkdir command is used to make the directories in the Linux kernel.
This command also creates multiple sub-directories inside one directory. mkdir stands for make directory.
With the mkdir command, we can make the directories in Linux.
Before Jumping on the command we should know the syntax of the mkdir command
mkdir [Option]… Directory …
1) How to Create Directory
To create only one directory in the current location then we can run the mkdir command.
$ mkdir FirstDirectory
2) How to Create Directory In Different Location –
To Create the Directory in some other location then we have to specify the full path of the location where we want to create the directory.
In this example, We are creating the directory inside /tmp directory.
$ mkdir /tmp/Directory2
3) How to Create Multiple Directory in A single Command
To create the 10 Directories using the single command then we can add the curly braces {} and define the number of Directories we want to create.
$ mkdir MultipleDirectories{1..10}
4)- How to Create Hidden Directory
To create the hidden directory using the mkdir command then we can add the ( . ) symbol before the name of the directory.
$ mkdir .HiddenDirectory
5) How to Create Multiple Directories With Different Names
To create multiple directories using the mkdir command then simply add the directories names after the mkdir command
If we don’t specify the location then the file will create in the current location only.
$ mkdir Dir1.txt Dir2.txt Dir3.txt Dir4.txt
6) How to create a directory with the space between the name of the directory
To create the directory and we need space between the name of the folder then we can do this with the help of the ” ” symbol.
$ mkdir "Devops Tut"
7) How to create the Nested Directories
To create the directory inside the parent directory
For Example. We want to create a nested directory then we can add the ( -p ) option in mkdir command ( -p ) is used to create parent directory inside the directory.
$ mkdir -p ParentDir/ChildDir1/ChildDir2
8) How To show the Message that the Directory is created
To print the message that the directory is created then we can use the ( -v ) option at the time of creating the directory. where ( -v ) is for verbose.
$ mkdir -v Directory
9) How to check version Of the mkdir command
To check what is the version of the mkdir command then we can execute the below command
$ mkdir --version
10) How to View the Most useful Options in the mkdir command
To know the most useful options with the mkdir command then we can execute below command
$ mkdir --help
Conclusion
If you want to learn Linux in the most simple language then please click on this link.
If you want to see the man page of mkdir command online then click on this link
This is the complete knowledge of how we can make directories in the Linux kernel using the mkdir command if you have any doubts please feel free to comment below. Please don’t forget to join our email subscription to get the latest updates on the Linux post.