Sunday, October 18, 2015
How To Run Gedit And Nautilus As Root With pkexec Instead Of gksu
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 and 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 authentication dialog under Unity |
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.
Until (if) Ubuntu adds these PolicyKit files by default, you can use the instructions below to install two custom policy files I've created for Nautilus and Gedit, which allows running these applications as root via pkexec (firstly install wget: "sudo apt-get install wget"):
- for Nautilus:
wget https://raw.githubusercontent.com/hotice/failsdownloads/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/failsdownloads/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
andpkexec 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.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment