The Cookie Machine - Click here to drag window

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

Views: 33,889     Votes:  15 
Tags: sudo   gui   gksu  
Link: 🔍 See Original Answer on Ask Ubuntu 🔗

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: November 24, 2022    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

$ sudo -H printenv | grep HOME

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  ⇩