I read this answer explaining that "sometimes" root can own something at /home/$USER
directory.
Can anyone give an example how to prove it. Just give a test case when something really bad happens, when I run
sudo gedit /etc/rc.local
edit file and save.
I got many downvotes trying to help OP out and comments flooded in saying that it is a crime to run gedit with sudo.
Can anyone give a real example?
I clearly explained why this question is not a duplicate. There is no answer specific to gedit to the linked question.
And it is important to explain why widely used sudo gedit
is bad, or not really, etc.
Well maybe it's a fantasy, but there are a number of people saying the same thing:
Why should I use gksudo for Gtk apps instead of sudo?
Why should users never use normal sudo to start graphical applications?
How to run a GUI program as a different user (Debian)?
Running Sudo Graphically
This mail archive may also be of interest to you.
So, let's test it.
2 brand new virtual boxes. Ubuntu 14.04. Never run firefox on them. What will happen when I run the command
sudo firefox
?This is the same (or at least very similar) for both virtual boxes. While firefox was running, I installed a youtube extension - a featured one. Then I closed firefox, and checked the output.
Well,
.ICEauthority
is fine! However...3 things in my home folder (
/home/tim/
) are owned by root (..
,.dbus
and.mozilla
). This is the same (or at least very similar) for both virtual boxes.So, does this matter. I wasn't sure, so I ran firefox, like this:
And this ugly error:
For the full terminal output (including firefox babble), see these two pastebins, here and here.
I can still run firefox as root by the way. But now more files have been changed:
Was this because I uploaded an image to imgur.com? Not sure.
How did I fix this?
chown
. I don't understand it, but the internet said to do it, and it's a Virtual Box so yolo.And that fixed it. Now the output is just the
..
file:And that's the same on my actual computer. Oh, and on my Kubuntu virtualbox:
Which I've never even run a sudo command on. So all is well. Just don't run
sudo
on a GUI application.Final test: run it with the
-H
and the-i
flags:and
And good news! Still, the only root "thing" is
..
. And I can runfirefox
without root.OP wants me to talk about Gedit.
I ran
Then installed some random plugins. This was the output:
Note that I can't even view the ownership of
.gvfs
so I did this:So running
sudo gedit
does change a file in my home directory to root.I can still open gedit, but this time I get some garbage out:
And that suggests there is another file (
~.local/share/recently-used.xbel
) that's been changed. I think this is the Recently used list of files and (lucky guess) I now no longer have my list of recently used files:There should be a file there called
output2.txt.save2
. My pronouns are He / HimAs far as
sudo gedit
, nothing dire, just poor practice, especially as of late. How much harder would it be to suggestsudo -H gedit
?What does happen?
You get a couple of root owned files in your home folder. One (
recently-used.xbel
) will likely return to user ownership. This can happen when a file is deleted and re-created. To see whatsudo gedit
has changed, runfind ~ -user root -group root
and see what is returned. By default, this is should be nothing.With that command, you may see a couple files owned by root. One would be a new
.file
,.gvfs
, and sooner or later a root-owned~/.cache/dconf
and the aforementionedrecently-used.xbel
.So no 'the sky is failing' stuff, but still. Now there have been reports that continued use causes other issues but not going to claim what I don't see here.
Also note that as of 13.10 a
sudo gedit
will use the user's gedit config rather than root's gedit config. Again just bad practice so why continue to do so or suggest others do so?