Home > System Tutorial > LINUX > body text

What command to create a directory in linux

下次还敢
Release: 2024-04-11 21:42:16
Original
432 people have browsed it

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

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>
    Copy after login
  • Create a directory named bar even if the parent directory does not exist:

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

    <code>mkdir -m 777 example</code>
    Copy after login

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!

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 Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template