I'm trying to be a good boy and stop using gksudo, especially since it just got orphaned in the 18.04 daily builds (note, this question is not specific to 18.04).

In the bad old days of using gksudo, I'd typically navigate to a folder containing the file I wish to edit (I use pcmanfm) then select Tools/Open Current Folder In Terminal from the menu. Then I'd type gksudo leafpad [file-I-wish-to-edit] in the newly opened terminal.

Using information in the very useful answer How to configure pkexec? I set my .bash_aliases and I am able to now type pkexec leafpad [file-I-wish-to-edit] in the newly opened terminal and I don't get any errors. Sadly, though I get a blank file instead of what I wanted. I have determined that this is because leafpad is looking in /root instead of the folder I wished to be in.

How can I maintain my halo, continue to use pkexec instead of gksudo, yet retain the functionality I'm used to?

  • It was orphaned in 16.04. Use sudo apt install gksu. Apr 21, 2018 at 1:14
  • I have the packages but I'd like to do things the proper way if it's not too much trouble. Surely this basic functionality is still available. Apr 21, 2018 at 1:18
  • 1
    Yes I too fell into the "proper way rabbit hole" when 16.04 was released. So I wrote the gsu script which I posted in the answer below. It's nicer because it doesn't dim all attached screens like gksu does. I guess it's nice because it "follows the rules" but I honestly have had no problems with gksu. The exception being using gksu gedit in Windows 10 (within WSL framework) where Windows 10 Ubuntu 16.04 messes up permissions within NTFS in the first place anyway. Apr 21, 2018 at 1:51

3 Answers 3


As mentioned in comments, gksu was "orphaned" in 16.04 but you can still install it with:

sudo apt install gksu

That said I made a wrapper script for pkexec a long time ago that might be of some interest:


# Usage: gsu gedit file1
#  -OR-  gsu natuilus /dirname

COMMAND="$1" # extract gedit or nautilus
ABSOLUTE_NAME=$(realpath "$2")


#log-file "$ABSOLUTE_NAME" ~/bin/log-gsu-"$COMMAND"

I named the wrapper gsu as a short form of gksu. The log-file script is a separate project which I commented out in the script for this answer.

You need to setup gedit and nautilus policy kits before you can use this script as the comments reference. In your case you would need to setup a policy kit for leafpad.

Hope this helps!

  • @OrganicMarble Actually it's my pleasure to finally share it with someone who might care a couple of years after writing it :) Apr 21, 2018 at 1:53
  • Thanks, this definitely helped me solve my problem. I wrote a wrapper script much like yours just for leafpad which incorporated pkexec just as you did. With this I can execute my use case that is spelled out in the question. I have to get used to typing gleafpad but I was going to have to get used to typing pkexec leafpad anyway. Many thanks. Apr 21, 2018 at 2:02
  • 1
    Another option is to call your script /home/your_user_name/bin/leafpad and it will be higher on the hierarchy list and call the regular leafpad in /bin or wherever it resides. Apr 21, 2018 at 2:07
  • It appears that for 18.04 they've taken gksu out of the repos, you can't even install it without manually downloading the packages. Apr 21, 2018 at 13:43
  • 1
    So no longer orphaned like 16.04 but kidnapped! Apr 21, 2018 at 14:10

I use this alternative in desktop launchers or bash scripts to keep the gksu feel:

bash -c 'sudo -i nautilus;'

... though no pkexec here - pls don't tell my admin.

  • 1
    You are recommending to use sudo with graphical applications, which, even which the -i option, allegedly is not appropriate. If it were so easy, we probably would not be concerned with pkexec or admin:// after lacking the old gksu.
    – vanadium
    Jul 9, 2018 at 7:25
  • sudo -H nautilus is safer Aug 26, 2018 at 3:14

Use something like pkexec thunar %f (thunar is the xfce file manager and %f is for current path - works with Bionic XFCE just like gksu).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.