In this article, we are going to learn about mkdir Command in Linux. The
mkdir is probably the most used command and for good reason. With it, we can create a new directory. The
mkdir command is used to create directories.
mkdir command is always used for creating new directories in Linux. We can easily create the directory using this command. if we want to use Sudo command then we can make a directory anywhere using this command without any hassle.
Linux mkdir Command Syntax
$ mkdir [OPTION] [DIRECTORY]
The command takes one or more directory names as its arguments.
How to Create a New Directory
To create a directory in Linux, pass the directory’s name as the argument to the mkdir command. The following command would create a single directory named dir1
$ mkdir dir1
You can verify that the directory was created by listing the contents using the ls command :
$ ls -l
drwxrwxr-x 2 linuxips linuxips 4096 Aug 13 16:15 dir1 Create multi Directory
The following command would create many directories with different names.
$ mkdir dir1 dir2 dir3
How to Create Parent Directories
A parent directory is a directory that is above another directory in the directory tree. To create parent directories, use the -p option
$ mkdir -p /home/linuxips/dir1/dir2/dir3
When the -p option is used, the command creates the directory only if it doesn’t exist.
So this is the
mkdir Command in Linux is used to create new directories. However, if you want to know more about this command’s usage, you can execute the “mkdir –help” command in Linux for accessing the help manual of this command. You can use it as you want. Enjoy!!!
Related Linux Tutorials: