Home > System Tutorial > LINUX > body text

Which command to use to create a directory in linux

下次还敢
Release: 2024-04-12 13:54:16
Original
535 people have browsed it

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>
Copy after login

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

<code class="shell">mkdir Documents</code>
Copy after login

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>
Copy after login

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>
Copy after login

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>
Copy after login

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!

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
Popular Tutorials
More>
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!