Executes a command as another user.
pkexec allows an authorized user to execute a PROGRAM as another user. If PROGRAM is not specified, the default shell will be run. If no username is specified, the program will be executed as the administrative superuser, root.
pkexec [--version] [--disable-internal-agent] [--help]
pkexec [--keep-cwd] [--user username] PROGRAM [ARGUMENTS...]
PROGRAM: The program to run.
ARGUMENTS: Arguments passed to the program.
--version: Output version information and exit.
--disable-internal-agent: Avoid registering a textual authentication agent.
--help: Output help text and exit.
--keep-cwd: Keep the current working directory (default is /home/<username>/).
--user <username>: Execute the command as the specified user.
Upon successful completion, the return value is that of the PROGRAM.
127: Authorization not obtained or an authentication error occurred.126: The user cancelled the authentication dialog.pkexec ls
pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY command
pkexec --user username command
Note: When using pkexec, the system will prompt for the administrator's password. Use it only when necessary and exercise caution with administrative privileges.