• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# mkdir
2
3
4## Command Function<a name="section1083613274175"></a>
5
6This command is used to create a directory.
7
8## Syntax<a name="section820913118178"></a>
9
10mkdir \[_-vp_\] \[_-m mode_\] \[_dirname..._\]
11
12## Parameters<a name="section1256834121718"></a>
13
14**Table  1**  Parameter description
15
16<a name="table1299mcpsimp"></a>
17<table><thead align="left"><tr id="row1305mcpsimp"><th class="cellrowborder" valign="top" width="21%" id="mcps1.2.4.1.1"><p id="p1307mcpsimp"><a name="p1307mcpsimp"></a><a name="p1307mcpsimp"></a><strong id="b209289681211447"><a name="b209289681211447"></a><a name="b209289681211447"></a>Parameter</strong></p>
18</th>
19<th class="cellrowborder" valign="top" width="52%" id="mcps1.2.4.1.2"><p id="p1309mcpsimp"><a name="p1309mcpsimp"></a><a name="p1309mcpsimp"></a><strong id="b16886221330"><a name="b16886221330"></a><a name="b16886221330"></a>Description</strong></p>
20</th>
21<th class="cellrowborder" valign="top" width="27%" id="mcps1.2.4.1.3"><p id="p1311mcpsimp"><a name="p1311mcpsimp"></a><a name="p1311mcpsimp"></a><strong id="b163527968011447"><a name="b163527968011447"></a><a name="b163527968011447"></a>Value Range</strong></p>
22</th>
23</tr>
24</thead>
25<tbody><tr id="row15431344183419"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p85331144163414"><a name="p85331144163414"></a><a name="p85331144163414"></a>--help</p>
26</td>
27<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p2053354433413"><a name="p2053354433413"></a><a name="p2053354433413"></a>Displays the parameters supported by the <strong id="b1177313015559"><a name="b1177313015559"></a><a name="b1177313015559"></a>mkdir</strong> command.</p>
28</td>
29<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p16533144473411"><a name="p16533144473411"></a><a name="p16533144473411"></a>N/A</p>
30</td>
31</tr>
32<tr id="row9543644193413"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p153374418344"><a name="p153374418344"></a><a name="p153374418344"></a>-m</p>
33</td>
34<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p9533114416343"><a name="p9533114416343"></a><a name="p9533114416343"></a>Sets the permissions on the directory to create.</p>
35</td>
36<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p553334414343"><a name="p553334414343"></a><a name="p553334414343"></a>N/A</p>
37</td>
38</tr>
39<tr id="row654224463420"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p853334414347"><a name="p853334414347"></a><a name="p853334414347"></a>-p</p>
40</td>
41<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p3533184493418"><a name="p3533184493418"></a><a name="p3533184493418"></a>Creates parent and child directories recursively.</p>
42</td>
43<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p753313443344"><a name="p753313443344"></a><a name="p753313443344"></a>N/A</p>
44</td>
45</tr>
46<tr id="row454234412343"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p153315440349"><a name="p153315440349"></a><a name="p153315440349"></a>-v</p>
47</td>
48<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p453344420349"><a name="p453344420349"></a><a name="p453344420349"></a>Prints detailed information about the directory creation process.</p>
49</td>
50<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p553313444343"><a name="p553313444343"></a><a name="p553313444343"></a>N/A</p>
51</td>
52</tr>
53<tr id="row17542644203418"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p853394453413"><a name="p853394453413"></a><a name="p853394453413"></a>directory</p>
54</td>
55<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p653315443342"><a name="p653315443342"></a><a name="p653315443342"></a>Specifies the directory to create.</p>
56</td>
57<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p1553344410344"><a name="p1553344410344"></a><a name="p1553344410344"></a>N/A</p>
58</td>
59</tr>
60</tbody>
61</table>
62
63## Usage<a name="section1294234115172"></a>
64
65>![](../public_sys-resources/icon-notice.gif) **NOTICE:**
66>For the files created on the FAT file system, the file permission attributes are the same as those of the mounted nodes. Currently, the node permissions include only user read and write. The  **group**  and  **others**  permissions do not take effect.
67>In addition, only the user read and write permissions can be modified. The read and write permissions are  **rw**  and  **ro**  only. Therefore, when the  **-m**  option is specified in the  **mkdir**  command, only  **777**  and  **555**  permissions are available for the created directory, and the execute permission does not take effect.
68
69## Example<a name="section1113345211713"></a>
70
71Run the following commands:
72
73-   mkdir testpath
74-   mkdir -m 777 testpath
75-   mkdir -pv testpath01/testpath02/testpath03
76
77## Output<a name="section10142201012"></a>
78
79```
80OHOS:/tmp$ mkdir testpath
81OHOS:/tmp$ ll
82total 2
83drwxrwxrwx 1 0 0 2048 1979-12-31 00:00 testpath/
84```
85
86Example 2: creating a directory with specified permissions
87
88```
89OHOS:/tmp$ mkdir -m 777 testpath
90OHOS:/tmp$ ll
91total 2
92drwxrwxrwx 1 0 0 2048 1979-12-31 00:00 testpath/
93```
94
95Example 3: creating directories recursively
96
97```
98OHOS:/tmp$ mkdir -pv testpath01/testpath02/testpath03
99mkdir: created directory 'testpath01'
100mkdir: created directory 'testpath01/testpath02'
101mkdir: created directory 'testpath01/testpath02/testpath03'
102OHOS:/tmp$ ll
103total 2
104drwxrwxrwx 1 0 0 2048 1979-12-31 00:00 testpath01/
105OHOS:/tmp$ ll testpath01/
106total 2
107drwxrwxrwx 1 0 0 2048 1979-12-31 00:00 testpath02/
108OHOS:/tmp$ ll testpath01/testpath02/
109total 2
110drwxrwxrwx 1 0 0 2048 1979-12-31 00:00 testpath03/
111```
112
113