Home  >  Article  >  System Tutorial  >  What is the function of mkdir command in linux

What is the function of mkdir command in linux

下次还敢
下次还敢Original
2024-04-11 19:24:19465browse

The mkdir command in Linux is used to create directories in the Linux operating system. Syntax: mkdir [options] . Options include: -p: create directories recursively; -m: set permissions; -v: display creation details. Usage example: mkdir new_dir, recursively create a directory: mkdir -p dir1/dir2/dir3, set permissions: mkdir -m 755 private.

What is the function of mkdir command in linux

The role of the mkdir command in Linux

The mkdir command is used to create directories (folders) in the Linux operating system ). It is one of the basic tools for creating organized files and directories.

Syntax:

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

Options:

  • -p: Recursively create directories and intermediate directories.
  • -m: Create a directory and set permissions.
  • -v: Display detailed information about creating the directory.

How to use:

The syntax is very simple. To create a directory, enter the following at the command line:

<code>mkdir <目录名称></code>

For example, to create a directory named "new_dir", use the following command:

<code>mkdir new_dir</code>

Create directories recursively :

Use the -p option to create directories recursively, including intermediate directories. This means that the parent directories will be created even if they do not exist.

For example, to create the nested directory "dir1/dir2/dir3", you can use the following command:

<code>mkdir -p dir1/dir2/dir3</code>

Set permissions:

Use # The ##-m option sets permissions when creating a directory. Permissions are expressed in octal numbers, for example:

    ##755
  • : users can read, write, and execute; groups and others can read and execute
  • 644
  • : Readable and writable by users; readable by groups and others
  • For example, to create a directory "private" with permissions 755, you can use the following command:
<code>mkdir -m 755 private</code>

Additional Tips:

The mkdir command does not accept full paths to directories. It can only create directories within the current directory.
  • Use the
  • ls -l
  • command to view the permissions and owners of the directory. Use the
  • rmdir
  • command to delete the directory (provided the directory is empty).

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