Common Linux commands (4) and common linux commands

Source: Internet
Author: User

Common Linux commands (4) and common linux commands

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 named after the specified file name at a specified location. To create a folder, you must have the write permission on the parent folder of the created folder. In addition, the created folder cannot have the same name as the name of its parent folder, that is, the same folder cannot have the same name (case sensitive ).


3. command parameters:

-M, -- mode, set the permission <mode> (similar to chmod)

-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


4. Command instance:

Instance 1:Create an empty directory

Command: mkdir test1


Instance 2:Recursively create multiple directories

Command: mkdir-p test2/test22


Instance 3:Create a directory with the permission of 777:

Command: mkdir-m 777 test3

Output:

[root@localhost test]# mkdir -m 777 test3[root@localhost test]# lldrwxr-xr-x 2 root root 4096 10-25 17:42 test1drwxr-xr-x 3 root root 4096 10-25 17:44 test2drwxrwxrwx 2 root root 4096 10-25 17:46 test3[root@localhost test]#
Note: The test3 permission is rwxrwxrwx.

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

Command: mkdir-v test4

Output:

[Root @ localhost test] # mkdir-v test4mkdir: The Created directory "test4"

Instance 5:Create a directory structure for a project using one command

Command: mkdir-vp scf/{lib/, bin/, doc/{info, product}, logs/{info, product}, service/deploy/{info, product }}

[Root @ localhost test] # mkdir-vp scf/{lib/, bin/, doc/{info, product}, logs/{info, product }, service/deploy/{info, product} mkdir: You have created the directory "scf" mkdir: You have created the directory "scf/lib" mkdir: You have created the directory "scf/bin" mkdir: you have created the "scf/doc" mkdir: You have created the "scf/doc/info" mkdir: You have created the "scf/doc/product" mkdir: you have created the "scf/logs" mkdir: You have created the "scf/logs/info" mkdir: You have created the "scf/logs/product" mkdir: you have created the "scf/service" mkdir: You have created the "scf/service/deploy" mkdir: You have created the "scf/service/deploy/info" mkdir directory: you have created a directory named "scf/service/deploy/product" [root @ localhost test] # tree scf/| -- bin | -- doc | -- info | -- product | -- lib | -- logs | -- info | -- product | -- service | -- deploy | -- info | -- product12 directories, 0 files [root @ localhost test] #

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.