applications get stuck launched with sudo
If I launch Thunar from the command line it works, but if I try to launch Thunar using sudo, only the icon on the status bar shows up but no window; the same problem happens with gparted, synaptic and double commander, what is wrong?
Solution 1:
gvfs admin backend - for elevated permissions with GUI tools
In Ubuntu 17.10 (gvfs >= 1.29.4) and newer versions you can use the gvfs admin backend. Notice that you need the full path, for example
thunar admin:///path/to/directory
gedit admin:///path/to/file
so if you want to manage your /etc
directory, you can use
thunar admin:///etc
In theory, the gvfs admin backend method (which uses PolicyKit) is better and safer (than xhost
and sudo -H
), regardless of the UI you use.
You don't run the whole application as root. Privilege escalation happens only when strictly necessary. See the following link and links from it,
-
sisco311's reply in the Ubuntu Forums thread 'Which best practice for using gedit as root?'
This is post #4. See also post #6 in the same thread.
pkexec
Alternatives to gksu
are developed in order to increase the security. Synaptic and Gparted work with pkexec
(another PolicyKit application). See man pkexec
.
You can run from a terminal window
pkexec synaptic
pkexec gparted
but the execution using PolicyKit is built into the graphical launch mechanism, so that you see only the pop up window asking for password.
But command line tools (in terminal windows) and sudo
are often recommended when elevated permissions are necessary. A file browser open with elevated permissions makes it easy to damage the operating system by mistake.