HiveBrain v1.2.0
Get Started
← Back to all entries
snippetbashTip

pkexec — Execute commands as another user. Asks for password in a GUI if available. See also: `sudo`, `run0`,

Submitted by: @import:tldr-pages··
0
Viewed 0 times
commandcommandsanotherasksexecutecliuserpkexec
linux

Problem

How to use the pkexec command: Execute commands as another user. Asks for password in a GUI if available. See also: sudo, run0, doas. More information: <https://polkit.pages.freedesktop.org/polkit/pkexec.1.html>.

Solution

pkexec — Execute commands as another user. Asks for password in a GUI if available. See also: sudo, run0, doas. More information: <https://polkit.pages.freedesktop.org/polkit/pkexec.1.html>.

Run command as root:
pkexec {{command}}


Switch user to root:
pkexec


Run command as a specific user:
pkexec --user {{username}} {{command}}

Code Snippets

Run command as root

pkexec {{command}}

Switch user to root

pkexec

Run command as a specific user

pkexec --user {{username}} {{command}}

Context

tldr-pages: linux/pkexec

Revisions (0)

No revisions yet.