1e41f4b71Sopenharmony_ci# mkdir 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ci 4e41f4b71Sopenharmony_ci## 命令功能 5e41f4b71Sopenharmony_ci 6e41f4b71Sopenharmony_cimkdir命令用来创建一个目录。 7e41f4b71Sopenharmony_ci 8e41f4b71Sopenharmony_ci 9e41f4b71Sopenharmony_ci## 命令格式 10e41f4b71Sopenharmony_ci 11e41f4b71Sopenharmony_cimkdir [_-vp_] [_-m mode_] [_dirname..._] 12e41f4b71Sopenharmony_ci 13e41f4b71Sopenharmony_ci 14e41f4b71Sopenharmony_ci## 参数说明 15e41f4b71Sopenharmony_ci 16e41f4b71Sopenharmony_ci**表1** 参数说明 17e41f4b71Sopenharmony_ci 18e41f4b71Sopenharmony_ci| 参数 | 参数说明 | 19e41f4b71Sopenharmony_ci| --------- | ------------------------------ | 20e41f4b71Sopenharmony_ci| --help | 查看mkdir命令支持的参数列表 | 21e41f4b71Sopenharmony_ci| -m | 设置即将创建目录的权限。 | 22e41f4b71Sopenharmony_ci| -p | 递归逐级创建父子目录。 | 23e41f4b71Sopenharmony_ci| -v | 打印创建目录过程中的详细信息。 | 24e41f4b71Sopenharmony_ci| directory | 需要创建的目录。 | 25e41f4b71Sopenharmony_ci 26e41f4b71Sopenharmony_ci 27e41f4b71Sopenharmony_ci## 使用指南 28e41f4b71Sopenharmony_ci 29e41f4b71Sopenharmony_ci> **须知:** 30e41f4b71Sopenharmony_ci> fatfs文件系统所有创建的文件和其挂载节点的权限属性保持一致,目前节点的权限只有用户读写权限,group和others权限不生效, 31e41f4b71Sopenharmony_ci> 32e41f4b71Sopenharmony_ci> 且只有读写位可设置,有rw和ro两种,因此mkdir在附加-m参数时,创建的目录权限仅有777和555两种,可执行权限也不生效。 33e41f4b71Sopenharmony_ci 34e41f4b71Sopenharmony_ci## 特殊说明 35e41f4b71Sopenharmony_ci 36e41f4b71Sopenharmony_cishell端暂不支持。切换mksh版本可全支持,方法:cd bin; ./mksh。 37e41f4b71Sopenharmony_ci 38e41f4b71Sopenharmony_ci## 使用实例 39e41f4b71Sopenharmony_ci 40e41f4b71Sopenharmony_ci举例: 41e41f4b71Sopenharmony_ci 42e41f4b71Sopenharmony_ci- mkdir testpath 43e41f4b71Sopenharmony_ci 44e41f4b71Sopenharmony_ci- mkdir -m 777 testpath 45e41f4b71Sopenharmony_ci 46e41f4b71Sopenharmony_ci- mkdir -pv testpath01/testpath02/testpath03 47e41f4b71Sopenharmony_ci 48e41f4b71Sopenharmony_ci 49e41f4b71Sopenharmony_ci## 输出说明 50e41f4b71Sopenharmony_ci 51e41f4b71Sopenharmony_ci 52e41f4b71Sopenharmony_ci``` 53e41f4b71Sopenharmony_ciOHOS:/tmp$ mkdir testpath 54e41f4b71Sopenharmony_ciOHOS:/tmp$ ll 55e41f4b71Sopenharmony_citotal 2 56e41f4b71Sopenharmony_cidrwxrwxrwx 1 0 0 2048 1979-12-31 00:00 testpath/ 57e41f4b71Sopenharmony_ci``` 58e41f4b71Sopenharmony_ci 59e41f4b71Sopenharmony_ci**示例2** 创建指定mode的目录 60e41f4b71Sopenharmony_ci 61e41f4b71Sopenharmony_ci 62e41f4b71Sopenharmony_ci``` 63e41f4b71Sopenharmony_ciOHOS:/tmp$ mkdir -m 777 testpath 64e41f4b71Sopenharmony_ciOHOS:/tmp$ ll 65e41f4b71Sopenharmony_citotal 2 66e41f4b71Sopenharmony_cidrwxrwxrwx 1 0 0 2048 1979-12-31 00:00 testpath/ 67e41f4b71Sopenharmony_ci``` 68e41f4b71Sopenharmony_ci 69e41f4b71Sopenharmony_ci**示例3** 逐级创建目录 70e41f4b71Sopenharmony_ci 71e41f4b71Sopenharmony_ci 72e41f4b71Sopenharmony_ci``` 73e41f4b71Sopenharmony_ciOHOS:/tmp$ mkdir -pv testpath01/testpath02/testpath03 74e41f4b71Sopenharmony_cimkdir: created directory 'testpath01' 75e41f4b71Sopenharmony_cimkdir: created directory 'testpath01/testpath02' 76e41f4b71Sopenharmony_cimkdir: created directory 'testpath01/testpath02/testpath03' 77e41f4b71Sopenharmony_ciOHOS:/tmp$ ll 78e41f4b71Sopenharmony_citotal 2 79e41f4b71Sopenharmony_cidrwxrwxrwx 1 0 0 2048 1979-12-31 00:00 testpath01/ 80e41f4b71Sopenharmony_ciOHOS:/tmp$ ll testpath01/ 81e41f4b71Sopenharmony_citotal 2 82e41f4b71Sopenharmony_cidrwxrwxrwx 1 0 0 2048 1979-12-31 00:00 testpath02/ 83e41f4b71Sopenharmony_ciOHOS:/tmp$ ll testpath01/testpath02/ 84e41f4b71Sopenharmony_citotal 2 85e41f4b71Sopenharmony_cidrwxrwxrwx 1 0 0 2048 1979-12-31 00:00 testpath03/ 86e41f4b71Sopenharmony_ci```