• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# su
2
3## Command Function<a name="section297810431676"></a>
4
5This command is used to switch the user account.
6
7## Syntax<a name="section157131147876"></a>
8
9su \[_uid_\] \[_gid_\]
10
11## Parameters<a name="section04145521671"></a>
12
13**Table  1**  Parameter description
14
15<a name="table1049mcpsimp"></a>
16<table><thead align="left"><tr id="row1055mcpsimp"><th class="cellrowborder" valign="top" width="21%" id="mcps1.2.4.1.1"><p id="p1057mcpsimp"><a name="p1057mcpsimp"></a><a name="p1057mcpsimp"></a>Parameter</p>
17</th>
18<th class="cellrowborder" valign="top" width="51.93%" id="mcps1.2.4.1.2"><p id="p1059mcpsimp"><a name="p1059mcpsimp"></a><a name="p1059mcpsimp"></a>Description</p>
19</th>
20<th class="cellrowborder" valign="top" width="27.07%" id="mcps1.2.4.1.3"><p id="p1061mcpsimp"><a name="p1061mcpsimp"></a><a name="p1061mcpsimp"></a>Value Range</p>
21</th>
22</tr>
23</thead>
24<tbody><tr id="row1062mcpsimp"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p1064mcpsimp"><a name="p1064mcpsimp"></a><a name="p1064mcpsimp"></a>uid</p>
25</td>
26<td class="cellrowborder" valign="top" width="51.93%" headers="mcps1.2.4.1.2 "><p id="p14138191243"><a name="p14138191243"></a><a name="p14138191243"></a>Specifies the ID of the target user.</p>
27</td>
28<td class="cellrowborder" valign="top" width="27.07%" headers="mcps1.2.4.1.3 "><a name="ul14151675449"></a><a name="ul14151675449"></a><ul id="ul14151675449"><li>Left blank</li><li>[0,60000]</li></ul>
29</td>
30</tr>
31<tr id="row172161126124218"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p12217026154215"><a name="p12217026154215"></a><a name="p12217026154215"></a>gid</p>
32</td>
33<td class="cellrowborder" valign="top" width="51.93%" headers="mcps1.2.4.1.2 "><p id="p48748461789"><a name="p48748461789"></a><a name="p48748461789"></a>Specifies the ID of the target user group.</p>
34</td>
35<td class="cellrowborder" valign="top" width="27.07%" headers="mcps1.2.4.1.3 "><a name="ul10433713134417"></a><a name="ul10433713134417"></a><ul id="ul10433713134417"><li>Left blank</li><li>[0,60000]</li></ul>
36</td>
37</tr>
38</tbody>
39</table>
40
41## Usage<a name="section14615155610719"></a>
42
43-   If no parameter is specified, the  **su**  command switches to user  **root**  by default. The  **uid**  and  **gid**  for user  **root**  are both  **0**.
44-   If  **uid**  and  **gid**  are specified, this command allows commands to be executed as the user with the specified  **uid**  and  **gid**.
45-   If the input parameter is out of the range, an error message will be printed.
46
47## Example<a name="section13338150985"></a>
48
49Run  **su 1000 1000**.
50
51## Output<a name="section125021924194613"></a>
52
53Switching to the user with both  **uid**  and  **gid**  of  **1000**:
54
55```
56OHOS # ls
57Directory /data/system/param:
58-rw-r--r-- 0 u:0 g:0 hello_1.txt
59OHOS # su 1000 1000
60OHOS # touch hello 2.txt
61OHOS # ls
62Directory /data/system/param:
63-rw-r--r-- O u:1000 g:1000 hello 2.txt
64-гw-r--r-- 0 u:0 g:0 hello_1.txt
65```
66
67