pkexec

Execute commands as other users

Supplementary instructions

pkexec Allows an authorized user to execute PROGRAM as another user. if not specified PROGRAM, the default shell will run. If no username is specified, the program will run as the administrative superuser root identity execution.

grammar

pkexec [--version] [--disable-internal-agent] [--help]
pkexec [--keep-cwd] [--user username] PROGRAM [ARGUMENTS...]

Options

PROGRAM Program to run
ARGUMENTS... Arguments passed to the program

--version output version number and exit
--disable-internal-agent avoid registering your own text authentication agent
--help print help text and exit
--keep-cwd running location, default is /home/<username>/
--user <username> User name to run

return value

On successful completion, the return value is the return value of PROGRAM.

Example

pkexec command

Replace command with the command you want to run with administrator privileges. For example, pkexec ls will run the ls command with administrator privileges.

pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY command

This command is used to run commands that require administrator privileges in the graphical interface. Replace command with the command you want to run with administrator privileges.

pkexec --user username command

Replace username with the username of the user you want to run the command as, and command with the command you want to run.

pkexec --help

This command will display instructions and a list of options for pkexec.

Note that when running a command using pkexec, you will be prompted for the administrator password to authenticate. Make sure to use pkexec only when necessary to run commands that require administrator privileges, and handle administrator privileges with caution.

References