I did some further testing on Ubuntu 18.04 pre-release to answer a reddit thread. The file managers
Nautilus, Nemo, Caja and Thunar all work with admin:// paths, as do the text editors
Gedit, Xed and Pluma. Opening an admin:// path in one of these file managers and then opening a text file from there with one of these text editors propagates the elevated privileges. You can also use admin:// paths as command line arguments to these programs.
For text editors that don't support it, like Nano or KDE's Kate or Xfce's Mousepad (latter two as examples; neither of those are used on Linux Mint), you can likely use sudoedit. sudoedit makes a user writable copy of a file, opens it with the user's preferred text editor and only after the file is closed uses elevated privileges to move the copied file back to the original location. For example:
sudoedit /etc/fstab
by default edits with Nano
EDITOR=mousepad sudoedit /etc/fstab
edits with Mousepad for a single command
- or you can set the environment variable
SUDO_EDITOR=/usr/bin/kate -b
to edit with Kate by default instead of Nano (the -b
option is specific for Kate, to make the editor wait for the file to be closed before returning; for Gedit and Xed use -w
instead)
Strangely, Dolphin and Kate don't seem to support either gvfs or polkit or offer an alternative (that I could easily discover). kdesudo is not available either and pkexec doesn't work with either program. So KDE users seem to have to use sudoedit. For them probably a convenient idea is to set up
SUDO_EDITOR=/usr/bin/kate -b
in their .bashrc.
As for other commands one would want to run with elevated privileges, like the backup of all user home directories (please share others!), that likely needs an additional short configuration file for pkexec if it isn't already available.