I need to check if I have an usable polkit agent in a desktop-environment agnostic way.

Right now, what I'm doing is to check if a polkit agent is running, using a code like this:

ps aux | grep some-polkit-agent

where some-polkit-agent may be:

  • polkit-gnome-authentication-agent-1 (for gnome2 and gnome3-fallback)
  • polkit-kde-authentication-agent-1 (for kde)
  • polkit-mate-authentication-agent-1 (for mate)
  • lxpolkit (for lxde)

The "no-fallback" gnome3 (gnome-shell) has its own polkit agent within the gnome-shell process itself, so I can't ps-grep it. What I assume is that if gnome-shell is running then the polkit agent is in place.

The problem comes when a system has hidepid enabled (see http://www.linux-dev.org/2012/09/hide-process-information-for-other-users/). This security measure makes that a ps doesn't show me any polkit agent running even if there is one.

Is there any better way that I can check for an usable polkit agent?

  • pkexec command will run command with sudo privileges. It'll give a popup asking to authenticate.
    – codehumor
    Jul 12, 2023 at 16:31

3 Answers 3


"I need to check if I have an usable polkit agent"

Presumably you want it to be usable for a specific process, either a process pid or since you cannot see pids, a system bus name?

In that case you could use "pkcheck" for the specific process and check its return value because the manual page for pkcheck says

   If the specificied process is not authorized because **no suitable**
   **authentication agent is available** or if the --allow-user-interaction
   wasn't passed, pkcheck exits with a return value of 2 and a diagnostic
   message is printed on standard error. Details are printed on standard

Agents register themselves to the polkit authority over dbus. If you could intercept their dbus traffic you would know exactly what agent is registered.

  • 1
    How would intercepting their dbus traffic be done?
    – Time4Tea
    Mar 23, 2020 at 14:54

Based on this forum post, you need to install the policykit-desktop-privileges package.

  • 1
    I don't need/want to install a polkit agent. I need a way to know if there is a polkit agent running. Mar 2, 2015 at 19:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .