• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# su<a name="EN-US_TOPIC_0000001179965841"></a>
2
3-   [Command Function](#section297810431676)
4-   [Syntax](#section157131147876)
5-   [Parameters](#section04145521671)
6-   [Usage](#section14615155610719)
7-   [Example](#section13338150985)
8-   [Output](#section125021924194613)
9
10## Command Function<a name="section297810431676"></a>
11
12This command is used to switch the user.
13
14## Syntax<a name="section157131147876"></a>
15
16su \[_uid_\] \[_gid_\]
17
18## Parameters<a name="section04145521671"></a>
19
20**Table  1**  Parameter description
21
22<a name="table1049mcpsimp"></a>
23<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>
24</th>
25<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>
26</th>
27<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>
28</th>
29</tr>
30</thead>
31<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>
32</td>
33<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>
34</td>
35<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>
36</td>
37</tr>
38<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>
39</td>
40<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>
41</td>
42<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>
43</td>
44</tr>
45</tbody>
46</table>
47
48## Usage<a name="section14615155610719"></a>
49
50-   The  **su**  command is used to switch to user  **root**  by default. The default value for both  **uid**  and  **gid**  is  **0**.
51-   If the  **uid**  and  **gid**  parameters are specified, this command can switch to the user with the specified  **uid**  and  **gid**.
52-   If the input parameter is out of the range, an error message will be printed.
53
54## Example<a name="section13338150985"></a>
55
56Run  **su 1000 1000**.
57
58## Output<a name="section125021924194613"></a>
59
60**Figure  1**  Switching to the user whose  **uid**  and  **gid**  are both  **1000**<a name="fig666918538448"></a>
61![](figure/switching-to-the-user-whose-uid-and-gid-are-both-1000.png "switching-to-the-user-whose-uid-and-gid-are-both-1000")
62
63