Home  >  Article  >  System Tutorial  >  Which command to use to create a directory in linux

Which command to use to create a directory in linux

下次还敢
下次还敢Original
2024-04-12 13:54:16651browse

In Linux, the command to create a directory is mkdir. It supports the creation of nested directories, the creation of multiple directories simultaneously, and provides options to control creation behavior, such as setting permissions and automatically creating parent directories.

Which command to use to create a directory in linux

Commands used to create directories in Linux

Creating directories is a common operation in Linux systems. It allows users to organize and manage files. In Linux, the command to create a directory is mkdir.

Use mkdir to create a directory

mkdir The basic syntax of the command is as follows:

<code class="shell">mkdir <目录名称></code>

For example, to create a directory named "Documents " directory, you can use the following command:

<code class="shell">mkdir Documents</code>

Create a nested directory

mkdir The command also allows the creation of nested directories, that is, in the current Create subdirectories within a directory. To create nested directories, use absolute or relative paths in the command.

For example, to create a nested directory "Documents/Projects", you can use the following command:

<code class="shell">mkdir Documents/Projects</code>

Create multiple directories

The mkdir command can create multiple directories at the same time by specifying multiple directory names in the command. Each directory name should be separated by spaces.

For example, to create the "Documents", "Projects" and "Personal" directories, you can use the following command:

<code class="shell">mkdir Documents Projects Personal</code>

Options

## The #mkdir command provides several options to control the directory creation behavior:

  • -m: Set the mode (permissions) of the directory.
  • -p: If it does not exist, the parent directory will be automatically created.
  • -v: Displays details for each directory being created.
  • --help: Display the help information of the command.
For example, to create the "Documents" directory with 755 permissions, you can use the following command:

<code class="shell">mkdir -m 755 Documents</code>

The above is the detailed content of Which command to use to create a directory in linux. 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