Skip to content

About running GUI applications as root

gksu and similar tools have been removed since Mint 19.- Prior to Ubuntu 18.04/Mint 19 follow gksu instructions.


IMPORTANT
Avoid running graphical applications as root if possible.


Edit file using GUI as root

The wrong way!

Never use sudo xed , sudo gedit or any sudo on GUI application to avoid to create file owned by root into your configuration.

The expected way

Access to privileged files and directories is possible through GVFS by specifying the admin backend in the URI scheme.

To access the expected file just add admin:// prefix

Samples

To edit /etc/fstab use:

xed admin:///etc/fstab

Other examples

xed admin:///etc/default/grub
gedit admin:///etc/samba/smb.conf

Tips

This mean than you can also use any URL like:

xed https://forums.linuxmint.com/viewtopic.php?t=268140

Of course you cannot save on the web site like this !

Run other GUI applications

To run GUI applications as root (not editor) and for same reasons, you shouldn't use sudo APP2RUN directly.

You must add following options to run into the root environment. * -u root : ensure to use root user * -i: run the shell specified by the target user's password database entry as a login shell.

Finally you have something like:

sudo -u root -i gparted

xhost - server access control program for X

TODOC

  • xhost si:localuser:root will allow to run those apps as root.
  • use xhost -si:localuser:root to remove permission afterwards.