su

Command Function

This command is used to switch the user.

Syntax

su [uid] [gid]

Parameters

Table 1 Parameter description

Parameter

Description

Value Range

uid

Specifies the ID of the target user.

  • Left blank
  • [0,60000]

gid

Specifies the ID of the target user group.

  • Left blank
  • [0,60000]

Usage

  • The su command is used to switch to user root by default. The default value for both uid and gid is 0.
  • If the uid and gid parameters are specified, this command can switch to the user with the specified uid and gid.
  • If the input parameter is out of the range, an error message will be printed.

Example

Run su 1000 1000.

Output

Figure 1 Switching to the user whose uid and gid are both 1000