Home> System Tutorial> LINUX> body text

What is the function of mkdir command in linux

下次还敢
Release: 2024-04-11 19:24:19
Original
405 people have browsed it

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:

mkdir [选项] <目录名称>
Copy after login

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:

mkdir <目录名称>
Copy after login

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

mkdir new_dir
Copy after login

Create directories recursively :

Use the-poption 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:

mkdir -p dir1/dir2/dir3
Copy after login

Set permissions:

Use # The ##-moption 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:
mkdir -m 755 private
Copy after login

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!

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 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!