📜  mkdir 子目录 (1)

📅  最后修改于: 2023-12-03 14:44:19.333000             🧑  作者: Mango

Introduction to the "mkdir" Command

The "mkdir" command is used to create a new directory or a subdirectory within an existing directory in a Unix or Linux environment. It stands for "make directory". This command is essential for organizing and managing files on a computer system.

Basic Syntax

The basic syntax of the "mkdir" command is as follows:

mkdir <directory_name>

Here, <directory_name> is the name of the directory you want to create. For example, to create a directory named "my_folder", you would enter:

mkdir my_folder
Creating Subdirectories

You can also use the "mkdir" command to create a new subdirectory within an existing directory. To do this, you will need to specify the path of the parent directory followed by the name of the new subdirectory. For example:

mkdir parent_folder/new_folder

In this example, "parent_folder" is an existing directory and "new_folder" is the name of the subdirectory you want to create within it.

Creating Multiple Directories

You can use the "mkdir" command to create multiple directories at once by specifying their names separated by a space. For example:

mkdir folder1 folder2 folder3
Options

The "mkdir" command also provides some options to modify its behavior. Here are some commonly used options:

  • -p or --parents: This option will create any parent directories that do not already exist. For example:

    mkdir -p parent_folder/new_folder
    

    This command will create both the "parent_folder" directory and the "new_folder" subdirectory within it.

  • -m or --mode: This option allows you to specify the permissions for the new directory. For example:

    mkdir -m 755 my_folder
    

    This command will create a new directory named "my_folder" with read, write, and execute permissions for the owner and read and execute permissions for others.

Conclusion

The "mkdir" command is a simple yet powerful tool for creating directories and subdirectories on a Unix or Linux system. By using its various options and syntax, you can easily organize and manage your files, making your work more efficient and productive.