LinuxCommandLibrary

pkexec

TLDR

Run command as root

$ pkexec [command]
copy
Switch to root shell
$ pkexec
copy
Run as specific user
$ pkexec --user [username] [command]
copy

SYNOPSIS

pkexec [--user username] [--disable-internal-agent] [command] [arguments...]

DESCRIPTION

pkexec executes programs as another user with privilege escalation via PolicyKit. Unlike sudo, it integrates with the desktop environment and can show graphical authentication dialogs when available.
Authorization decisions are based on PolicyKit policies, allowing fine-grained control over which users can run which programs with elevated privileges. Actions can be configured to require authentication or be allowed without it.

PARAMETERS

--user _username_

Run as specified user instead of root
--disable-internal-agent
Don't use built-in authentication agent
--keep-cwd
Keep current working directory

CAVEATS

Requires polkitd daemon running. Graphical prompt needs authentication agent (often desktop-environment specific). Environment is sanitized by default. Not a drop-in sudo replacement.

HISTORY

pkexec is part of PolicyKit (polkit), developed by David Zeuthen at Red Hat. It provides a modern privilege escalation mechanism that integrates with desktop environments and supports fine-grained authorization policies.

SEE ALSO

sudo(8), doas(1), run0(1), polkit(8)

Copied to clipboard