Linuxmkdircommand to create a directory of the specified name, requiring the user who created the directory to have write permissions in the current directory, and the specified directory name cannot be a directory that is already in the current directory. 1. Command format:mkdir[options] Directory ...2. Command function: Throughmkdircommand to create a folder or directory that is named DirName (the specified file name) at the specified location. The user who creates the folder or directory must have write permissions to the parent folder of the folder that is created. Also, the folder (directory) You create cannot have the same name as the filename 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 permissions < mode > (Similarchmod), instead of rwxrwxrwx minus Umask-P,--parents can be a path name. In this case, if some directories in the path do not already exist, and with this option, the system will automatically establish those that do not already exist, that is, multiple directories can be established at one time; -V,--verbose displays information each time a new directory is created--Help displays this information and exits--version output release information and exit4. Command instance: Instance 1: Create an empty directory command:mkdirtest1 output: [[email protected] soft]# CD Test[[email protected] test]#mkdirTest1[[email protected] test]# ll total 4drwxr-xr-x2Root root4096 Ten- - -: theTest1[[email protected] test] #实例2: Recursively create multiple directory commands:mkdir-P test2/test22 output: [[email protected] test]#mkdir-P test2/Test22[[email protected] test]# ll total 8drwxr-xr-x2Root root4096 Ten- - -: theTEST1DRWXR-xr-x3Root root4096 Ten- - -: -Test2[[email protected] test]# CD test2/[[email protected] test2]# ll total 4drwxr-xr-x2Root root4096 Ten- - -: -Test22[[email protected] test2] #实例3: Create a directory command with permission 777:mkdir-M777test3 output: [[email protected] test]#mkdir-M777Test3[[email protected] test]# ll total 12drwxr-xr-x2Root root4096 Ten- - -: theTEST1DRWXR-xr-x3Root root4096 Ten- - -: -test2drwxrwxrwx2Root root4096 Ten- - -: $Test3[[email protected] test] #说明: Test3 permissions are rwxrwxrwx instance 4: Creating a new directory displays the information command:mkdir-v test4 output: [[email protected] test]#mkdir-v test4mkdir: Created directory "Test4" [[email protected] test]#mkdir-VP test5/test5-1mkdir: The directory "Test5" was createdmkdir: Directory Created "test5/test5-1[[email protected] test] #实例五: A command to create a directory structure for a project reference: http://www.ibm.com/developerworks/cn/aix/library/au-badunixhabits.htmlcommand:mkdir-VP scf/{lib/,bin/,doc/{Info, product},logs/{Info, product},service/deploy/{Info, Product}} Output: [[email protected] test]#mkdir-VP scf/{lib/,bin/,doc/{Info, product},logs/{Info, product},service/deploy/{Info, product}}mkdir: The directory "SCF" has been createdmkdir: Directory Created "scf/Lib "mkdir: Directory Created "scf/bin "mkdir: Directory Created "scf/Doc "mkdir: Directory Created "scf/doc/Info"mkdir: Directory Created "scf/doc/Product "mkdir: Directory Created "scf/Logs "mkdir: Directory Created "scf/logs/Info"mkdir: Directory Created "scf/logs/Product "mkdir: Directory Created "scf/Service "mkdir: Directory Created "scf/service/Deploy "mkdir: Directory Created "scf/service/deploy/Info"mkdir: Directory Created "scf/service/deploy/product "[[email protected] test]# tree SCF/SCF/|--bin|--Doc| |--Info| `--Product|--Lib|--logs| |--Info| `--Product '--Service '--Deploy|--Info `--Product ADirectories,0Files[[email protected] test]#
Linux Commands learning Note (4): mkdir command