Home >System Tutorial >LINUX >What command to create a directory in linux

What command to create a directory in linux

下次还敢
下次还敢Original
2024-04-11 21:42:16478browse

The command to create a directory in Linux is mkdir, and the syntax is: mkdir [option] directory name. Options include: -p creates a parent directory; -v outputs detailed information; -m sets permission mode. Examples: mkdir foo creates the foo directory; mkdir -p /tmp/bar creates the /tmp/bar directory even if /tmp/ does not exist; mkdir -m 777 example creates the example directory with permissions 777.

What command to create a directory in linux

The command to create a directory in Linux: mkdir

The mkdir command is used to create a directory (folder) in Linux )The command. The syntax is simple:

<code>mkdir [选项] 目录名</code>

where options are optional and directoryname is the name of the directory you want to create.

Options:

  • -p: Creates all necessary parent directories. For example, to create the /tmp/foo/bar directory if /tmp/foo does not exist, use mkdir -p /tmp/foo/bar.
  • -v: Output the details of the created directory.
  • -m mode: Set the permission mode of the directory. For example, mkdir -m 755 foo will create the foo directory with permissions 755.

Example:

  • Create a directory named foo:

    <code>mkdir foo</code>
  • Create a directory named bar even if the parent directory does not exist:

    <code>mkdir -p /tmp/bar</code>
  • Create a directory named example directory with permissions 777:

    <code>mkdir -m 777 example</code>

Note:

  • When creating a directory, you need to have write permissions on the parent directory .
  • Directory names cannot contain spaces or special characters.

The above is the detailed content of What command 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