UPDATE
I would like to know which is the recommend way of running GUI applications as root, mainly because what I'm trying isn't running smoothly. I get some annoying warnings that makes me think whether I'm doing something wrong or not.
I'm using gksudo
and sudo -i
, which I understand, are doing the same thing. Please let me know if there is some slight differences between them.
Regarding the problems I'm experiencing, I would like to start with nautilus (run as root). I can't edit the preferences file maybe because the program couldn't create its own configuration files. A warning says that the folder /root/.config/nautilus
must be created. When you start an application for the first time, the program is responsible for creating the configuration files it will potentially need. So, when you are running as root, it should happen the same, shouldn't it?
Furthermore, in the shell appears some strange warnings while running this application, such as the followings:
(nautilus:3406): Gtk-WARNING **: Failed to register client: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.gnome.SessionManager was not provided by any .service files
Nautilus-Share-Message: Called "net usershare info" but it failed: The "shared network" returned error 255: net usershare: cannot open usershare directory /var/lib/samba/usershares. Error It doesn't exist the file or the folder
Please ask your system administrator to enable user sharing.
Other applications like gedit or firefox complained in this way:
(gedit:3444): Gtk-WARNING **: Calling Inhibit failed: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.gnome.SessionManager was not provided by any .service files
(gedit:3444): GLib-GIO-WARNING **: Failed to parse translated string ''Monospace 12'' for key 'editor-font' in schema 'org.gnome.gedit.preferences.editor': 0:expected value
(gedit:3444): GLib-GIO-WARNING **: Using untranslated default instead.
(firefox:2719): Gtk-CRITICAL **: IA__gtk_clipboard_set_with_data: assertion 'targets != NULL
I want to make a clean install of the system soon, but before that, I would like to understand how it works in case I need this stuff in the future for specific things. Though I know it's safer to use the straight sudo in the command line instead.
Why this is happening? Thanks in advance
Best Answer
The issue with using a straight
sudo nautilus
is that it will sometimes try to use configuration files from your user's home directory. This can cause root (superpriviledged user) to change permissions on files within your home directory. This is not usually harmful long-term; it can cause annoying problems like refusing to login to your desktop, but you can usually restore previous configurations by typing:So what
gksudo
andsudo -i
do is simply to tell the program to run with either copies of.Xauthority
and other configuration files or with ones that actually belong to root. I personally prefersudo -i
so I don't have to type in my password every time, but it's totally preference. The two commands are doing the same thing.