Sometimes I need to edit files in /etc
. I know I can do this with the console (sudo mv some/file /etc/some/file
, sudo nano /etc/some/file
) etc, but I find this way a bit clunky. Call me spoiled, but I'm really used to GUI tools such as Nautilus and Gedit.
Distributions such as Ubuntu Mate or Mint make it easy: I can right click a folder and then a context menu appears with options such as "open as administrator". From then double-clicking a text file opens it in gedit with elevated privileges.
However, I can't find such an option in the default Unity version of Ubuntu:
Note:
- I am aware of the question Ways to run Nautilus with elevated privileges , but the solution recommended here is to use
gksudo
, which no longer works - I suppose I can always do
sudo gedit /etc/whatever
, but - AFAIK - usingsudo
with GUI tools is heavily ill-advised - I recall some say that it is ill-advised to run GUI tools with elevated privileges at all. This doesn't seem to be the case, however, since some default GUI tools themselves ask for elevation, Ubuntu Software being perhaps one of the most prominent examples:
Is there a way to run Nautilus or Gedit with elevated privileges?
admin://
thing should also work with other GNOME utilities like gedit. – muru Oct 22 '21 at 14:39gedit admin:///PathToRootFile
. – Paul Benson Oct 22 '21 at 14:41GDBus.Error:org.freedesktop.PolicyKit1.Error.Failled: Unix process subject does not have uid set
– gaazkam Oct 22 '21 at 16:08xed admin://..........
works fine with Mint as it did when I used gedit with Ubuntu, so I don't believe anything has changed. So eg,gedit admin:///etc/hosts
should open your hosts file after typing your password. – Paul Benson Oct 22 '21 at 18:13GDBus.Error:org.freedesktop.PolicyKit1.Error.Failled: Unix process subject does not have uid set
. Ubuntu 21.10, default version (not Lubuntu, Kubuntu or any other remix) – gaazkam Oct 22 '21 at 18:40sudo -H
. ex:sudo -H gedit /etc/filename
. – heynnema Oct 22 '21 at 19:32id -ng myusername
does it show you as a sudo member? – Paul Benson Oct 23 '21 at 06:39id -ng m
only printsm
, but I still can use sudo.groups m
showsm adm cdrom sudo dip plugdev lpadmin lxd sambashare
. – gaazkam Oct 23 '21 at 08:12sudo
for GUI apps, instead usegksudo
/pkexec
/admin://
/whatever else
/absolutely nothing, never run GUI apps as root
" I'm a bit surprised to read that I can usesudo -H
to run GUI apps... But hey, it works :) – gaazkam Oct 23 '21 at 08:22sudo -H
"requests that the security policy set the HOME environment variable to the home directory specified by the target user's password database entry." (cont) – gaazkam Nov 11 '21 at 19:44-H
option "makes it safe to run GUI apps withsudo
" and so, I believe, your answer should explain why and howsudo -H
is "the" proper way to elevate the rights of a GUI app. – gaazkam Nov 11 '21 at 19:49