• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# su
2
3
4## Command Function
5
6This command is used to switch the user account.
7
8
9## Syntax
10
11su [_uid_] [_gid_]
12
13
14## Parameters
15
16**Table 1** Parameter description
17
18| Parameter| Description| Value Range|
19| -------- | -------- | -------- |
20| uid | Specifies the ID of the target user.| - Left blank<br>- [0, 60000] |
21| gid | Specifies the ID of the target user group.| - Left blank<br>- [0, 60000] |
22
23
24## Usage Guidelines
25
26- If no parameter is specified, the **su** command switches to user **root** by default. The **uid** and **gid** for user **root** are both **0**.
27
28- If **uid** and **gid** are specified, this command allows commands to be executed as the user with the specified **uid** and **gid**.
29
30- If the input parameter is out of the range, an error message will be printed.
31
32
33## Example
34
35Run **su 1000 1000**.
36
37
38## Output
39
40The user with both **uid** and **gid** of **1000** is switched.
41
42```
43OHOS # ls
44Directory /data/system/param:
45-rw-r--r-- 0 u:0 g:0 hello_1.txt
46OHOS # su 1000 1000
47OHOS # touch hello 2.txt
48OHOS # ls
49Directory /data/system/param:
50-rw-r--r-- O u:1000 g:1000 hello 2.txt
51-гw-r--r-- 0 u:0 g:0 hello_1.txt
52```
53