Use the mkdir command to create directories and subdirectories under Linux _linux

Source: Internet
Author: User
Tags mkdir parent directory

This article describes the use of the mkdir command to create directories and subdirectories under Linux, and now we want to learn to create directories under Linux systems. Under Linux, we can use the mkdir command. Mkdir is the abbreviation for "Make directory".

What's mkdir?

Mkdir is a command to create a directory under a Linux system. This command belongs to the built-in command.

Run mkdir command

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

$ mkdir

By default, running the mkdir command with no parameters creates a directory in the current directory. The following is a reference example:

As shown in the figure above, we created a directory called 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 discovers that the directory you want to create already exists, Linux prompts us that Linux cannot create it.

Another prerequisite for creating a directory is that you must have access rights under the target path where you want to create the directory. MKDIR will report this error when you cannot get permission.

Create multiple Catalogs

We can also create multiple catalogs at the same time. For example, we want to create a directory with Ubuntu, Redhat and Slackware. Then the grammar will look like this:

$ mkdir Ubuntu Redhat Slackware

Add a directory containing subdirectories [to create a directory recursively]

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

$ mkdir-p Letter/important

Set access Permissions

With the-m parameter, we can set permissions for the new directory that will be generated. Examples are as follows:

$ mkdir-m=r--Letter

The above command creates a directory named letter and gives read-only access to directory owners, user groups, and other users for that directory

Print process information for creating a directory

If we want to view the information, we can use the-v argument to implement it. Examples are as follows:

$ mkdir-v Ubuntu Redhat Slackware

Summarize

The Mkdir command is also one of the most basic commands that must be mastered for a friend who wants to learn Linux. As always, you can type man mkdir or mkdir--help to display the MkDir manual page and explore more deeply.

The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.