Linuxstar
Published on

mkdir command-create a directory

Jonas

Jonas

1 min read
The mkdir command is short for "make directories" and is used to create directories. Note: By default, if the directory to be created already exists, it will prompt that it already exists, and will not continue to create the directory. Therefore, when creating a directory, you should ensure that the newly created directory does not have the same name as the file in the directory. The mkdir command can also create multiple directories at the same time, is it very powerful?

Syntax:

mkdir [parameter] [directory]

Command parameters

-p Recursively create multi-level directories
-m Set the permissions of the directory while creating the directory
-z Set the security context
-v Show catalog creation process

Example

In the working directory, create a subdirectory named dir:
[root@linuxstar ~]# mkdir dir
Create a subdirectory dir under the directory /usr/linuxstar, and set the file owner to have read, write and execute permissions, and other people have no right to access
[root@linuxstar ~]# mkdir -m 700 /usr/linuxstar/dir
Create subdirectories dir1, dir2, dir3 at the same time:
[root@linuxstar ~]# mkdir dir1 dir2 dir3
Create directories recursively:
[root@linuxstar ~]# mkdir -p linuxstar/dir