search
Homephp教程PHP开发How to use the mkdir command to create directories and subdirectories under Linux

This article introduces the use of mkdir command to create directories and subdirectories under Linux. Now we have to learn to create directories under Linux system. Under Linux, we can use the mkdir command. Mkdir is an abbreviation for "make directory".

What is mkdir?

Mkdir is a command used to create directories under Linux systems. This command is a built-in command.

Run the mkdir command

You can use it by typing mkdir directly in your console.

$ mkdir

By default, running the mkdir command without any parameters will create a directory under the current directory. The following is a reference example:

Linux下用 mkdir 命令来创建目录和子目录

As you can see from the above picture, we have created a directory named office. When we run the mkdir command, we are in the /home/pungki directory. So this new directory office is created in the /home/pungki directory. If we use an absolute path - for example: /usr/local -, Linux will create a directory under the /usr/local directory.

When Linux finds that the directory you want to create already exists, Linux will prompt us that Linux cannot create it.

Linux下用 mkdir 命令来创建目录和子目录

Another first condition for creating a directory is that you must have access permissions in the target path where you want to create the directory. mkdir will report this error when you are unable to obtain permissions.

Create multiple directories

We can also create multiple directories at the same time. For example, the directories we want to create include ubuntu, redhat and slackware. Then the syntax will look like this:

$ mkdir ubuntu redhat slackware

Add a directory containing subdirectories [Annotation: Create directories recursively]

When the directory you want to create contains subdirectories, you need to use the -p parameter. If mkdir cannot find the parent directory, this parameter will help create the parent directory first. For example, we want to create a directory named letter, which contains the subdirectory important. Then the syntax will look like this:

$ mkdir -p letter/important

Linux下用 mkdir 命令来创建目录和子目录

Set access permissions

Using the -m parameter, we can set permissions for the new directory to be generated. An example is as follows:

$ mkdir -m=r-- letter

The above command will create a directory named letter and grant read-only permissions to the directory owner, user group and other users

Linux下用 mkdir 命令来创建目录和子目录

Print the process of creating the directory Information

If we want to view information, we can use the -v parameter to achieve this. An example is as follows:

$ mkdir -v ubuntu redhat slackware

Summary

Mkdir command is also one of the most basic commands. Friends who want to learn Linux must master this command. As usual, you can type man mkdir or mkdir --help to display the mkdir man page and discuss it in more depth.

The above is the entire content of this article. I hope it will be helpful to everyone’s learning. I also hope that everyone will support the PHP Chinese website.

How to use the mkdir command to create directories and subdirectories under Linux

For more related articles about how to use the mkdir command to create directories and subdirectories under Linux, please pay attention to 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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor