Home> System Tutorial> LINUX> body text

What does linux mkdir -p mean?

下次还敢
Release: 2024-04-11 19:21:17
Original
802 people have browsed it

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?

Linuxmkdir -pCommand: Create a multi-level directory

What Is it themkdir -pcommand?

mkdir -pis a Linux command used to create multi-level directories. Unlike the normalmkdircommand,mkdir -pcan recursively create non-existing parent directories.

Syntax

mkdir -p [选项] 目录
Copy after login

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 -pThe 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 themkdir -pcommand, use the following steps:

  1. Open the terminal.
  2. Type the following command:
mkdir -p /home/user/Documents/NewFolder
Copy after login

This command will create a directory namedDocumentsin the/home/userdirectory, and Create a directory namedNewFolderwithin theDocumentsdirectory.

Advantages

The main advantages of using themkdir -pcommand 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!

Related labels:
source:php.cn
Statement of this Website
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!