Home >System Tutorial >LINUX >What does linux mkdir -p mean?

What does linux mkdir -p mean?

下次还敢
下次还敢Original
2024-04-11 19:21:171107browse

Linux mkdir -p command is used to create multi-level directories, including non-existent parent directories. It has the advantages of simplifying directory creation, preventing errors and improving efficiency.

What does linux mkdir -p mean?

Linux mkdir -p Command: Create a multi-level directory

What Is it the mkdir -p command?

mkdir -p is a Linux command used to create multi-level directories. Unlike the normal mkdir command, mkdir -p can recursively create non-existing parent directories.

Syntax

<code>mkdir -p [选项] 目录</code>

Options

  • -m Mode: Set the permissions of the directory .
  • -v: Show detailed output, including directories created.
  • -Z: Sets the SELinux context for the directory.

Function

mkdir -p The command works in the following way:

  1. If the specified directory does not If it exists, create it.
  2. If the parent directories of the specified directories do not exist, create them recursively.
  3. Then, the specified directory is created using the specified permissions (if provided).

Example

To create a multi-level directory using the mkdir -p command, use the following steps:

  1. Open the terminal.
  2. Type the following command:
<code>mkdir -p /home/user/Documents/NewFolder</code>

This command will create a directory named Documents in the /home/user directory, and Create a directory named NewFolder within the Documents directory.

Advantages

The main advantages of using the mkdir -p command are:

  • Simplify multi-level Directory Creation: No need to manually create each parent directory.
  • Prevent errors: If the parent directory does not exist, it will be created automatically, eliminating the need to create them manually.
  • Improve efficiency: Save time and energy.

The above is the detailed content of What does linux mkdir -p mean?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn