You can use pkexec
instead of gksudo
. My way of running eg. gedit
with elevated privileges is to create a script, for example /usr/local/bin/su_gedit
, with the following contents:
#!/bin/bash
pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY gedit $*
Then you can create a .desktop
file for this script, for example /usr/share/applications/su_gedit.desktop
(I have not tested if other location than /usr/share/applications
will work), copying its contents from org.gnome.gedit.desktop
and modifying appropriately, ie. changing the Name=
and Comment=
lines to whatever you want (for example Name=Root Text Editor
and Comment=Edit text files with root privileges
) and replacing gedit
by /usr/local/bin/su_gedit
in all Exec=
lines.
After you do this, when right-clicking in Nautilus on a file that normally opens in gedit, and selecting "Open with a different program", you should see your "Root Text Editor" entry on the list. Even if it isn't there, if you click "Show all programs" button, you should be able to choose it.
Another way is to create a similar script that runs elevated gnome-terminal
, and create a launcher for that script eg. in your GNOME panel or on the desktop. From that terminal, you can simply run gedit
as root. That's what I usually do.