When should I use pkexec and when sudo -i?
Solution 1:
The basic use is the same - the programs in question allow you to run other programs as another user, usually root. The difference, however, between sudo
variants and pkexec
is that sudo
gives a program total control over everything, while with pkexec
you have a much more fine grained control by defining a policy for each program.
If you trust the programs that you run, sudo is perfectly fine. If you want to really lock down everything and permit programs to do only what you allow them to, then use pkexec
that comes along with polkit.
While the idea behind pkexec
is nice, I wouldn't go as far as calling it the next gksu
, due to the complex set up needed.
Reference: the difference between sudo and pkexec on Quora.