Linux Command: mkdir command learning and use, linuxmkdir

Source: Internet
Author: User

Linux Command: mkdir command learning and use, linuxmkdir

The linux mkdir command is used to create a directory with the specified name. The user who creates the directory must have the write permission in the current directory, and the specified directory name cannot be an existing directory in the current directory.

1. Command Format:

Mkdir [Option] Directory...

2. command functions:

The mkdir command can be used to create a folder or directory named by DirName at a specified position. To create a folder or directory, you must have the write permission on the parent folder of the created folder. In addition, the created folder (directory) cannot have the same name as the file name in its parent directory (that is, the parent folder), that is, the same directory cannot have the same name (case sensitive ).

3. command parameters:

-M,-mode = mode, set the permission <mode> (similar to chmod), rather than rwxrwxrwx minus umask

-P,-parents can be a path name. If some directories in the path do not exist, after this option is added, the system will automatically create those directories that do not exist, that is, multiple directories can be created at a time;

-V,-verbose displays information every time a new directory is created

-Help: displays the help information and exits.

-Version: Output version information and exit

4. Command instance:

Instance 1: Create an empty directory

Command:

Mkdirtest1

Output:

[Root @ localhostsoft] # cdtest

[Root @ localhosttest] # mkdirtest1

[Root @ localhosttest] # ll

Total 4drwxr-xr-x2rootroot409610-2517: 42test1

[Root @ localhosttest] #

Example 2: recursively create multiple directories

Command:

Mkdir-ptest2/test22.

Output:

[Root @ localhosttest] # mkdir-ptest2/test22

[Root @ localhosttest] # ll

Total 8drwxr-xr-x2rootroot409610-2517: 42test1

Drwxr-xr-x3rootroot409610-2517: 44test2.

[Root @ localhosttest] # cdtest2/

[Root @ localhosttest2] # ll

Total 4drwxr-xr-x2rootroot409610-2517: 44test22

[Root @ localhosttest2] #

Instance 3: create a directory with the 777 permission

Command:

Mkdir-m777test3

Output:

[Root @ localhosttest] # mkdir-m777test3

[Root @ localhosttest] # ll

Total 12drwxr-xr-x2rootroot409610-2517: 42test1

Drwxr-xr-x3rootroot409610-2517: 44test2.

Drwxrwxrwx2rootroot409610-2517: 46test3.

[Root @ localhosttest] #

Note:

Test3 permission: rwxrwxrwx

Instance 4: information is displayed when a new directory is created.

Command:

Mkdir-vtest4

Output:

[Root @ localhosttest] # mkdir-vtest4

Mkdir: The Directory test4 has been created"

[Root @ localhosttest] # mkdir-vptest5/test5-1

Mkdir: The Directory test5 has been created"

Mkdir: Directory test5/test5-1 created"

[Root @ localhosttest] #

Example 5: A command is used to create the directory structure of a project.

Reference: https://www.ibm.com/developerworks/cn/aix/library/au-badunixhabits.html

Command:

Mkdir-vpscf/{lib/, bin/, doc/{info, product}, logs/{info, product}, service/deploy/{info, product }}

Output:

[Root @ localhosttest] # mkdir-vpscf/{lib/, bin/, doc/{info, product}, logs/{info, product}, service/deploy/{info, product }}

Mkdir: the "scf" directory has been created"

Mkdir: You have created the "scf/lib" directory"

Mkdir: You have created the "scf/bin" directory"

Mkdir: the "scf/doc" directory has been created"

Mkdir: the "scf/doc/info" directory has been created"

Mkdir: the "scf/doc/product" directory has been created"

Mkdir: You have created the "scf/logs" directory"

Mkdir: You have created the "scf/logs/info" directory"

Mkdir: You have created the "scf/logs/product" directory"

Mkdir: the "scf/service" directory has been created"

Mkdir: You have created the "scf/service/deploy" directory"

Mkdir: the directory "scf/service/deploy/info" has been created"

Mkdir: the directory "scf/service/deploy/product" has been created"

[Root @ localhosttest] # treescf/

Scf/

|-Bin

|-Doc

|-Info

| '-Product

|-Lib

|-Logs

|-Info

| '-Product

'-Service

'-Deploy

|-Info

'-Product

12 directories, 0 files

[Root @ localhosttest] #

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.