How To Install pkexec on Debian 12

Learn how to install pkexec on Debian 12 with this tutorial. pkexec is run commands as another user with polkit authorization

Introduction

In this tutorial we learn how to install pkexec on Debian 12.

What is pkexec

pkexec is:

polkit is an application-level toolkit for defining and handling the policy that allows unprivileged processes to speak to privileged processes. It was previously named PolicyKit.

pkexec is a setuid program to allow certain users to run commands as root or as a different user, similar to sudo. Unlike sudo, it carries out authentication and authorization by sending a request to polkit, so it uses desktop environments’ familiar prompting mechanisms for authentication and uses polkit policies for authorization decisions.

By default, members of the ‘sudo’ Unix group can use pkexec to run any command after authenticating. The authorization rules can be changed by the local system administrator.

If this functionality is not required, removing the pkexec package will reduce security risk by removing a setuid program.

There are three methods to install pkexec on Debian 12. We can use apt-get, apt and aptitude. In the following sections we will describe each method. You can choose one of them.

Install pkexec Using apt-get

Update apt database with apt-get using the following command.

sudo apt-get update

After updating apt database, We can install pkexec using apt-get by running the following command:

sudo apt-get -y install pkexec

Install pkexec Using apt

Update apt database with apt using the following command.

sudo apt update

After updating apt database, We can install pkexec using apt by running the following command:

sudo apt -y install pkexec

Install pkexec Using aptitude

If you want to follow this method, you might need to install aptitude first since aptitude is usually not installed by default on Debian. Update apt database with aptitude using the following command.

sudo aptitude update

After updating apt database, We can install pkexec using aptitude by running the following command:

sudo aptitude -y install pkexec

How To Uninstall pkexec on Debian 12

To uninstall only the pkexec package we can use the following command:

sudo apt-get remove pkexec

Uninstall pkexec And Its Dependencies

To uninstall pkexec and its dependencies that are no longer needed by Debian 12, we can use the command below:

sudo apt-get -y autoremove pkexec

Remove pkexec Configurations and Data

To remove pkexec configuration and data from Debian 12 we can use the following command:

sudo apt-get -y purge pkexec

Remove pkexec configuration, data, and all of its dependencies

We can use the following command to remove pkexec configurations, data and all of its dependencies, we can use the following command:

sudo apt-get -y autoremove --purge pkexec

Dependencies

pkexec have the following dependencies:

References

Summary

In this tutorial we learn how to install pkexec package on Debian 12 using different package management tools: apt, apt-get and aptitude.