One Linux command per day (3) mkdir command

Source: Internet
Author: User

The mkdir command is used to create the directory. This command creates a directory named by DirName.     If no pathname is added before the directory name, the directory specified by DirName is created under the current directory, and if an existing path is given, a specified directory will be created under that directory. When creating a directory, make sure that the new directory does not have the same name as the file in the directory it is in.

(1) Usage:    

mkdir [Options] ... Directory...

(2) function:

Create a directory if the specified directory does not exist

(3) Option parameters

1)-Z: Set security context, valid when SELinux is used

2)-m:< target properties > or-mode< Target properties > Set directory permissions while setting up the directory

3)-P or--parents if the top-level directory to be set up is not currently established, the upper-level directory will be created

4)-version display version information

(4) Example

1) [[email protected] documents]$ mkdir maindir Create a new file under the current folder

[email protected] documents]$ ll             0 [[ Email protected] documents]$ mkdir maindir//Create a new file [[email protected] documents]$            ll 0 DRWXRWXR 2 6 may  1: Maindir

2) [[email protected] documents]$ mkdir-v seconddir Create a new file under the current folder, and output a message

[Email protected] documents]$ mkdir-

3) [[email protected] documents]$ mkdir-p THIRDDIR/{TEST1,TEST2,TEST3} Create a new clip under the current folder with multiple subfolders

[Email protected] documents]$ mkdir-p thirddir/{TEST1,TEST2,TEST3}//Create a new folder with multiple subfolders [email protected] documents]$ LL//view the files and folders under the current working directory to output total in detail0DRWXRWXR-X.2Sunjimeng Sunjimeng6May1  Geneva: theMAINDIRDRWXRWXR-X.2Sunjimeng Sunjimeng6May1  Geneva: theSECONDDIRDRWXRWXR-X.5Sunjimeng Sunjimeng theMay1  Geneva: $Thirddir[[email protected] documents]$ CD Thirddir//Enter directory [[email protected] thirddir]$ ll//view subdirectories under Directory total0DRWXRWXR-X.2Sunjimeng Sunjimeng6May1  Geneva: $TEST1DRWXRWXR-X.2Sunjimeng Sunjimeng6May1  Geneva: $TEST2DRWXRWXR-X.2Sunjimeng Sunjimeng6May1  Geneva: $Test3[[email protected] thirddir]$
[[email protected] documents]$ ll//view files and folders under the Document folder Total0DRWXRWXR-X.2Sunjimeng Sunjimeng6May1  Geneva: theMAINDIRDRWXRWXR-X.2Sunjimeng Sunjimeng6May1  Geneva: theSECONDDIRDRWXRWXR-X.5Sunjimeng Sunjimeng theMay1 Geneva: onThirddir[[email protected] documents]$ mkdir thirddir/{test4,test5,test6}//Although the Thirddir folder already exists, but does not affect this operation [[email protected] documents]$ ll Total0DRWXRWXR-X.2Sunjimeng Sunjimeng6May1  Geneva: theMAINDIRDRWXRWXR-X.2Sunjimeng Sunjimeng6May1  Geneva: theSECONDDIRDRWXRWXR-X.8Sunjimeng Sunjimeng +May1 Geneva: onThirddir[[email protected] documents]$ CD Thirddir[[email protected] thirddir]$ ll//For The set of subfolders under the new duplicate name folder will be added to the0DRWXRWXR-X.2Sunjimeng Sunjimeng6May1  Geneva: $TEST1DRWXRWXR-X.2Sunjimeng Sunjimeng6May1  Geneva: $TEST2DRWXRWXR-X.2Sunjimeng Sunjimeng6May1  Geneva: $TEST3DRWXRWXR-X.2Sunjimeng Sunjimeng6May1 Geneva: onTEST4DRWXRWXR-X.2Sunjimeng Sunjimeng6May1 Geneva: onTEST5DRWXRWXR-X.2Sunjimeng Sunjimeng6May1 Geneva: onTest6

4) [[email protected] documents]$ mkdir-m 700/home/sunjimeng/document Create a folder under the specified path, and only the file owner has read, write, and Execute permissions and no one else has access.

[Email protected] documents]$ mkdir-m the/home/sunjimeng/Document[[email protected] documents]$ CD/home/Sunjimeng[[email protected]~]$ lltotal0drwxr-xr-x.2Sunjimeng Sunjimeng6May1  on: atdesktopdrwx------.2Sunjimeng Sunjimeng6May1 Geneva: -Document//This item is the newly created folder drwxr-xr-x.5Sunjimeng SunjimengWuyiMay1  Geneva: $DOCUMENTSDRWXR-xr-x.2Sunjimeng Sunjimeng6May1  on: atDOWNLOADSDRWXR-xr-x.2Sunjimeng Sunjimeng6May1  on: atMUSICDRWXR-xr-x.2Sunjimeng Sunjimeng6May1  on: atPICTURESDRWXR-xr-x.2Sunjimeng Sunjimeng6May1  on: atPUBLICDRWXR-xr-x.2Sunjimeng Sunjimeng6May1  on: atTEMPLATESDRWXR-xr-x.2Sunjimeng Sunjimeng6May1  on: atVideos

5) [[email protected] document]$ mkdir-pm bin/os_1 in the current directory to establish the bin and bin Os_1 directory, the permissions are set to the main file readable, write, execute, the same group of users can read and execute, other users do not have access to the /c1>

 [[email protected] document]$ mkdir-pm 750  bin/os_1[[email protected] document]$ lltotal  0  DRWXRWXR -x 3  sunjimeng sunjimeng 17  may 1  03 : 13   bin[[email protected] document]$ CD bin[[email protected] bin]$ Lltotal  0  drwxr -X---. 2  sunjimeng sunjimeng 6  may 1  03 : 13   os_1[[email protected] bin]$    

    6)

 [[email protected] document]$ mkdir--versionmkdir (GNU coreutils)  Span style= "color: #800080;" >8.22  copyright (C)  2013   free software Foundation, inc.license GPLv3  +: GNU GPL version 3  or later < ; Http:// GNU.ORG/LICENSES/GPL.HTML>.  This is  free  software:you is free   to the change and redistribute it. There  is   NO WARRANTY, to the extent Permitted by law. Written by David MacKenzie.  

7) [[email protected] document]$ mkdir--parents father/child and mkdir-p father/child effect is the same as the same-m equivalent to--mood

[Email protected] document]$ mkdir--parents father/Child[[email protected] document]$ lltotal0DRWXRWXR-X.3Sunjimeng Sunjimeng -May1 Geneva: -BINDRWXRWXR-X.3Sunjimeng Sunjimeng -May1 Geneva: +Father[[email protected] document]$ CD Father[[email protected] father]$ lltotal0DRWXRWXR-X.2Sunjimeng Sunjimeng6May1 Geneva: +Child[[email protected] father]$

One Linux command per day (3) mkdir command

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.