Ubuntu / Linux news and application reviews.

gksu hasn't been updated since 2009 and is not recommended any more. In fact, Ubuntu no longer ships with gksu by default (though it may be installed for many of you, because some apps still depend on it) and it may even be completely removed at some point.

The recommended replacement for gksu is pkexec. Applications like Synaptic, Ubuntu Software Center, Software & Updates and others use it for some time but what if you want to use pkexec with applications like Gedit or Nautilus?

By default, you can't because pkexec can't run graphical applications without having a PolicyKit file installed in /usr/share/polkit-1/actions/ for the app you're trying to run as root, and Ubuntu doesn't ship with PolicyKit files for Nautilus or Gedit.

pkexec Unity
pkexec authentication dialog under Unity

pkexec GNOME Shell
pkexec authentication dialog under GNOME Shell

For instance, Nemo comes with a such a file and so do Xfce's Thunar and Mousepad (Xubuntu 15.04), but Nautilus and Gedit don't support this by default.

There are two ways you can achieve this though:

A) Install Nautilus Admin

Nautilus admin is a Nautilus extension that adds PolicyKit files for both Nautilus and Gedit and it allows opening a file or folder from Nautilus as root, via PolicyKit:




To install Nautilus Admin in Ubuntu, use the following command:
sudo apt-get install nautilus-admin
And restart Nautilus:
nautilis -q


B) Install PolicyKit files manually for Nautilus and Gedit

- for Nautilus:
wget https://raw.githubusercontent.com/hotice/webupd8/master/org.gnome.nautilus.policy -O /tmp/org.gnome.nautilus.policy
sudo cp /tmp/org.gnome.nautilus.policy /usr/share/polkit-1/actions/

- for Gedit:
wget https://raw.githubusercontent.com/hotice/webupd8/master/org.gnome.gedit.policy -O /tmp/org.gnome.gedit.policy
sudo cp /tmp/org.gnome.gedit.policy /usr/share/polkit-1/actions/

If you want to install these files manually, grab them from here: Nautilus | Gedit.

That's it! Now give it a try - open a terminal and type:
pkexec gedit
and
pkexec nautilus
For quick access, you can create launchers for running Nautilus and Gedit as root: simply use "pkexec nautilus" or "pkexec gedit" as the command.