Please provide Ubuntu documentation that refutes this: https://help.ubuntu.com/community/RootSudo Why, on my fully updated 13.04 system, does pkexec not function?
$ pkexec gedit somefile.txt
No protocol specified
** (gedit:13135): WARNING **: Could not open X display
Cannot open display:
Run '/usr/bin/gedit --help' to see a full list of available command line options
Why it doesn't work?
By default
pkexec
does not allow you to run graphical (X11) applications. From the man page:As stated in the man page, you can make it work albeit I really don't know if this is somehow dangerous or recommended.
To enable gedit for example you can create
/usr/share/polkit-1/actions/com.ubuntu.gedit.policy
with the following content:Then
pkexec gedit
should work as expected:As you can guess, this will only make
gedit
work. In theory, if you addedallow_gui
to "org.freedesktop.policykit.exec" (the default action) this should work for all applications, but in my tests I got the same result as yours.Why is pkexec preferred?
Here you can find a discussion about the strengths of
pkexec
.