Score:1

applications get stuck launched with sudo

it flag

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?

vanadium avatar
cn flag
No one ever should run graphical applications with `sudo` ever. @HuHa the suggestions you provide are greatly outdated by now (e.g. gksudo is not anymore in the repos for years), and certainly will not work when running on Wayland (default again on Ubuntu 21.10) instead of Xorg
HuHa avatar
es flag
"Nobody ever" is one of those fundamentalist nonsense pragmas that drives me up the walls. How do you expect users to use _synaptic_, _gparted_, _qdirstat_? They all need root permissions to be useful. This attitude is what makes users go "screw those security dudes, they make the system completely unusable!" and use relaxed security settings for _everything_.
HuHa avatar
es flag
This is probably `sudo` not importing `DISPLAY` from your environment. See also here: https://askubuntu.com/questions/175611/cannot-connect-to-x-server-when-running-app-with-sudo
HuHa avatar
es flag
The rationale for this default is that it is generally considered an avoidable security hazard to run GUI programs with root permissions. Of course _gparted_ and _synaptic_ really _need_ root permissions.
sudodus avatar
jp flag
Alternatives to `gksu` are developed in order to increase the security. Synaptic and Gparted work with `pkexec`, that applies PolicyKit. I don't know about Double Commander, maybe it still needs `sudo -H`.
Score:4
jp flag

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,

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.

it flag
pkexec synaptic does not work, the same for pkexec gparted
sudodus avatar
jp flag
@arpho, `pkexec` works for me with `synaptic` and `gparted`. It works for me in Ubuntu 20.04.3 LTS both in X and Wayland sessions. Which flavour (maybe Xubuntu because you ask about Thunar) and which version are you running ( other than 20.04.3 LTS)? Or some other flavour or version? Or maybe a non-Ubuntu distro? - If you let us know details about your operating system, it will be easier to help you. Otherwise there will only be general advice.
nobody avatar
gh flag
for synaptic `synaptic-pkexec`
sudodus avatar
jp flag
@arpho, use what works for *you*, maybe it is necessary to switch session from Wayland to X and/or use `xhost` and `sudo -H`. [This link](https://askubuntu.com/questions/961967/why-dont-gksu-gksudo-or-launching-a-graphical-application-with-sudo-work-with-w/961978#961978) (written 2017 and slightly modified after that) shows details of some methods.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.