One Linux command per day-mkdir

Source: Internet
Author: User

mkdir a command to create a directory on a Linux system that requires the user to have write permission on the path where the directory was created, and that the newly created directory name cannot be a directory that already exists.


Mdkir-make Directories

    1. Command format

      mkdir [option] [directories]

    2. Command description

      Create the DIRECTORY (ies), if they does not already exist.

      Create a directory (possibly multiple), if this directory does not exist to create, require users to create a directory with the Write permission to create a path, the directory name is case-sensitive

    3. Command parameters

      -m< Directory properties > or--mode< Directory properties > set directory permissions at the same time when the directory is established.

      -P or--parents if the parent directory you want to create has not been created, the parent directory is created together

      --HELP Display Help information

      -V or--verbose displays detailed information when executed.

      --version Display mkdir version information

    4. Command instance

      Example 1: Create an empty directory; Create a data directory under the/root directory

      Command:

Mkdir/root/data

Command output:

[Email protected] ~]# mkdir/root/data[[email protected] ~]# ls-ld/root/datadrwxr-xr-x. 2 root root 4096 June 02:21/root/data[[email protected] ~]#

Example 2: Create a directory recursively; a command to create such a directory structure/root/data/a/b/c/d/e/f/g

Command:

Mkdir-p/root/data/a/b/c/d/e/f/g

Command output:

[[email protected] ~]# mkdir-p/root/data/a/b/c/d/e/f[[email protected] ~]# tree/root/data/root/data '--a '--b '--C '--d '--e '--F6 directories, 0 files[[email protected] ~]#

Example 3: Create a directory with directory permissions of 777; Create a/root/test directory with permissions of 777

Command:

Mkdir-m 777/root/test

Command output

[Email protected] ~]# mkdir-m 777/root/test[[email protected] ~]# ls-ld/root/testdrwxrwxrwx. 2 root root 4096 June 02:30/root/test[[email protected] ~]#

Example 4: Create a directory, display create information, create a/root/backup directory, you need to see the directory creation information

Command:

Mkdir-v/root/backup

Command output:

[Email protected] ~]# mkdir-v/root/backupmkdir:created directory '/root/backup ' [[email protected] ~]#

Example 5: A command to create a directory structure for a project;

Command:

Mkdir-vp/root/mkdirtest/{bin,sbin,lib,lib32,config/{conf.d,conf/{conf1,conf2}},info/{infomation/{},readme}}

Command output:

[[Email protected] ~]# mkdir -vp /root/mkdirtest/{bin,sbin,lib,lib32,config/{conf.d, conf/{conf1,conf2}},info/{infomation,readme}}   mkdir: created directory  '/root/ Mkdirtest ' mkdir: created directory  '/root/mkdirtest/bin ' mkdir: created directory   '/root/mkdirtest/sbin ' mkdir: created directory  '/root/mkdirtest/lib ' mkdir: created  directory  '/root/mkdirtest/lib32 ' mkdir: created directory  '/root/mkdirtest/config ' mkdir: created directory  '/ROOT/MKDIRTEST/CONFIG/CONF.D ' mkdir: created directory   '/root/mkdirtest/config/conf ' mkdir: created directory  '/root/mkdirtest/config/conf/conf1 ' mkdir: created directory  '/root/mkdirtest/config/conf/conf2 ' mkdir: created directory   '/root/mkdirtest/info ' mkdir: created directory  '/root/mkdirtest/info/infomation ' mkdir:  created directory  '/root/mkdirtest/info/readme ' [[email protected] ~]# tree /root/mkdirtest/root/ mkdirtest|-- bin|-- config|   |-- conf|   |   |--  conf1|   |    '-- conf2|    '-- conf.d|-- info |   |-- infomation|    '-- readme|-- lib|-- lib32 '--  sbin12 directories, 0 files[[email protected] ~]#






One Linux command per day-mkdir

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.