The Cookie Machine - Click here to drag window

DUMMY TEXT - Real text set in assets/js/theCookieMachine.js

If you can read me, I'm broken!

Views: 36,334     Votes:  15 
Tags: sudo   gui   gksu  
Link: 🔍 See Original Answer on Ask Ubuntu ⧉ 🔗

URL: https://askubuntu.com/q/1047413
Title: Why should users never use normal sudo to start graphical applications?
ID: /2018/06/17/Why-should-users-never-use-normal-sudo-to-start-graphical-applications_
Created: June 17, 2018    Edited:  June 12, 2020
Upload: September 15, 2024    Layout:  post
TOC: false    Navigation:  false    Copy to clipboard:  false


Ubuntu 19.10 update

As of Ubuntu 19.10, typing sudo some_command now has the same effect as typing sudo -H some_command. This means the directory for any configuration files touched will be under /root directory and not /home/regular_userID directory (aka $HOME).

This makes this whole Q&A a moot point to a large degree for Ubuntu 19.10 users and greater.

To see whether sudo is working like sudo -H in your distribution try these short tests:

$ sudo printenv | grep HOME
HOME=/home/rick

$ sudo -H printenv | grep HOME
HOME=/root

As you can see, sudo above does not perform like sudo -H so using plain sudo can harm your user configuration files.


An alternative to gksu nautilus, gksu gedit or sudo -H gedit is to use the nautilus-admin add-on. It allows you to browse files and directories with Nautilus and then open them as root (Administrator).

Installation is straight forward:

sudo apt install nautilus-admin

Now when you are in Nautilus you’ll have an extra option to Edit as administrator:

nautilus admin.gif


gedit as root doesn’t allow preferences

When you run gedit as root you can’t use the preferences you’ve set up as a regular user for tab stops, convert tabs to spaces, font name, font size, line wrap, etc.

To solve this I’ve written the script sgedit to inherit user preferences and apply them to root: How can I sync my root gedit with my user gedit's preferences?

⇧ source command error from /usr/share/bash-completion/bash-completion when I open a terminal Remove playlist from Rhythmbox  ⇩