In Nemo you can browse to a folder, right click on the background in the file display area and select 'open as root.' Displaying a file from the window will then open the editor with elevated privileges.

This works in caja also.

Nope,
Just upgraded from 18.3 to 19 and this particular feature is gone. And I need it badly.

There are only few extensions installed by default. The one you are looking for is:

The edit as administrator function is hardcoded to use pluma as the editor though, so you'll either have to install that, modify the script or install caja-actions and just define your own menu entry to do that.

Last edited by gm10 on Thu Jul 05, 2018 8:56 am, edited 1 time in total.

The edit as administrator function is hardcoded to use pluma as the editor though, so you'll either have to install that, modify the script or install caja-action and just define your own menu entry to do that.

Thank you very much! This has saved me a lot of trouble. I suppose I can freely remove gksu altogether?

It's been removed by about every other distro as upstream it was discontinued years ago. The fact that Ubuntu still has it in the universe repo is more a symptom of that state of that repo than anything else.

In Nemo you can browse to a folder, right click on the background in the file display area and select 'open as root.' Displaying a file from the window will then open the editor with elevated privileges.

This works in caja also.

Nope,
Just upgraded from 18.3 to 19 and this particular feature is gone. And I need it badly.

Go to /usr/bin/ and make a symbolic link to pkexec. Call it "gksu":
cd /usr/bin
sudo ln -s pkexec gksu

I have fallen foul of the gksu removal, and none of the discussions I haver seen in this thread come anywhere near my use case AFAIK, so use of admin:// etc does not seem to work.

My use case is having a simple bash script to mount/unmount several windows shares using a command of the form "mount.cifs ${server}/${sleaf:-$remote} $Mount_point_root/$leaf -o $Options" which is invoked in a looper to mount several shares when I am on a particular network.

This bash script was itself invoked by a .desktop file using a line of the form 'Exec=gksu -S "/home/tim/bin/mounter/mount.sh woodentop"'

using admin:///home/tim/bin/mounter/mount.sh woodentop fails with a "no such file or directory" error

using pkexec /home/tim/bin/mounter/unmount.sh woodentop pops up a password window similar to gksu but then fails with a "Unable to init server: Could not connect: Connection refused"

I suspect this may be because some form of config file is needed somewhere in a policykit config folder but I cannot readily relate the man page example to my use case as it seems to refer to options that I have no equivalent for.

You can replace gksu with sudo and set Terminal=true in the .desktop file. That way the script will run in a terminal and you can enter your password on the terminal. You were only using gksu because it provided you with a dialog to enter your password I assume. So you can instead use the regular sudo password prompt on the terminal. This is the easiest and most future proof.

Alternatively you can install an askpass program and use that to provide sudo with a dialog to enter your password. A dialog similar to what gksu provided for your script. For example the package ssh-askpass-gnome provides an askpass program you can use for this. After installing it you can run a command like:SUDO_ASKPASS=/usr/lib/openssh/gnome-ssh-askpass sudo -A bash
and it will show a dialog prompt to enter your password, after which it will run bash as root. If you have just one command in your script that needs root, just prefix it in your script with that (replace bash in above with your command) and you can remove gksu from your .desktop file. If you have multiple commands that need root in your script you'll have to tinker with your .desktop file a bit. Likely you'll need to replace the Exec command with something like this to be able to set the SUDO_ASKPASS variable:
Exec=bash -c 'SUDO_ASKPASS=/usr/lib/openssh/gnome-ssh-askpass sudo -A "/home/tim/bin/mounter/mount.sh woodentop"'

Alternatively you can install an askpass program and use that to provide sudo with a dialog to enter your password. A dialog similar to what gksu provided for your script. For example the package ssh-askpass-gnome provides an askpass program you can use for this. After installing it you can run a command like:SUDO_ASKPASS=/usr/lib/openssh/gnome-ssh-askpass sudo -A bash
and it will show a dialog prompt to enter your password, after which it will run bash as root. If you have just one command in your script that needs root, just prefix it in your script with that (replace bash in above with your command) and you can remove gksu from your .desktop file. If you have multiple commands that need root in your script you'll have to tinker with your .desktop file a bit. Likely you'll need to replace the Exec command with something like this to be able to set the SUDO_ASKPASS variable:
Exec=bash -c 'SUDO_ASKPASS=/usr/lib/openssh/gnome-ssh-askpass sudo -A "/home/tim/bin/mounter/mount.sh woodentop"'