Question about GUI and root?

Quick to answer questions about finding your way around Linux Mint as a new user.
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions use the other forums in the support section.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
Iridule
Level 1
Level 1
Posts: 4
Joined: Fri Feb 03, 2023 1:19 pm

Question about GUI and root?

Post by Iridule »

Hello, I just started using linux mint 20.3 a few weeks ago. Last week I successfully learned to compile the kernel 6.1.8 for my desktop. All works fine. Now I am trying to learn some more about the proper way to use some commands yet get various answers online so would like to make sure I am doing this correctly. Sometimes I need to use nemo as root. I am using pkexec nemo Is this the correct way? I notice preferences such as sorting folders are not saved and some errors exist.
Image
Image
Last edited by LockBot on Thu Aug 03, 2023 10:00 pm, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Petermint
Level 9
Level 9
Posts: 2981
Joined: Tue Feb 16, 2016 3:12 am

Re: Question about GUI and root?

Post by Petermint »

Open terminal. sudo nemo
There are errors with most programs when used this way. There are dangers with running any program as root. Nemo as root can open files like /etc/hosts for editing. In the case of hosts, a safer way is to leave nemo as normal and sudo xed /etc/hosts
User avatar
Pjotr
Level 23
Level 23
Posts: 19886
Joined: Mon Mar 07, 2011 10:18 am
Location: The Netherlands (Holland) 🇳🇱
Contact:

Re: Question about GUI and root?

Post by Pjotr »

Petermint wrote: Sat Feb 04, 2023 5:21 am Open terminal. sudo nemo
There are errors with most programs when used this way. There are dangers with running any program as root. Nemo as root can open files like /etc/hosts for editing. In the case of hosts, a safer way is to leave nemo as normal and sudo xed /etc/hosts
Don't do that! This can seriously damage the permissions in your /home. :shock:

This is the safe and recommended way to do it:
https://easylinuxtipsproject.blogspot.c ... -root.html
Tip: 10 things to do after installing Linux Mint 21.3 Virginia
Keep your Linux Mint healthy: Avoid these 10 fatal mistakes
Twitter: twitter.com/easylinuxtips
All in all, horse sense simply makes sense.
User avatar
Bleys
Level 4
Level 4
Posts: 426
Joined: Wed Apr 20, 2022 4:17 am
Location: Essen, Germany

Re: Question about GUI and root?

Post by Bleys »

especially for nemo: Open Settings -> Context Menus -> Activate: Open as Root
Ryzen 5 5600G, 16GB RAM, 2TB M.2 Crucial P3, Asrock Deskmeet X300, Samsung Odyssey 49", Linux Mint 21
Iridule
Level 1
Level 1
Posts: 4
Joined: Fri Feb 03, 2023 1:19 pm

Re: Question about GUI and root?

Post by Iridule »

Pjotr wrote: Sat Feb 04, 2023 6:10 am
Petermint wrote: Sat Feb 04, 2023 5:21 am Open terminal. sudo nemo
There are errors with most programs when used this way. There are dangers with running any program as root. Nemo as root can open files like /etc/hosts for editing. In the case of hosts, a safer way is to leave nemo as normal and sudo xed /etc/hosts
Don't do that! This can seriously damage the permissions in your /home. :shock:

This is the safe and recommended way to do it:
https://easylinuxtipsproject.blogspot.c ... -root.html
I was using pkexec however I read if it isnt set up properly it will run as root anyways? seems confusing. I am not sure how to set it up.
User avatar
Pjotr
Level 23
Level 23
Posts: 19886
Joined: Mon Mar 07, 2011 10:18 am
Location: The Netherlands (Holland) 🇳🇱
Contact:

Re: Question about GUI and root?

Post by Pjotr »

Iridule wrote: Sat Feb 04, 2023 11:09 am
Pjotr wrote: Sat Feb 04, 2023 6:10 am This is the safe and recommended way to do it:
https://easylinuxtipsproject.blogspot.c ... -root.html
I was using pkexec however I read if it isnt set up properly it will run as root anyways? seems confusing. I am not sure how to set it up.
No worries; the Ubuntu and Mint devs have already set up pkexec for you, for the most common applications that might need to be used with root permissions from time to time.
Tip: 10 things to do after installing Linux Mint 21.3 Virginia
Keep your Linux Mint healthy: Avoid these 10 fatal mistakes
Twitter: twitter.com/easylinuxtips
All in all, horse sense simply makes sense.
Iridule
Level 1
Level 1
Posts: 4
Joined: Fri Feb 03, 2023 1:19 pm

Re: Question about GUI and root?

Post by Iridule »

Pjotr wrote: Sat Feb 04, 2023 2:59 pm
Iridule wrote: Sat Feb 04, 2023 11:09 am
Pjotr wrote: Sat Feb 04, 2023 6:10 am This is the safe and recommended way to do it:
https://easylinuxtipsproject.blogspot.c ... -root.html
I was using pkexec however I read if it isnt set up properly it will run as root anyways? seems confusing. I am not sure how to set it up.
No worries; the Ubuntu and Mint devs have already set up pkexec for you, for the most common applications that might need to be used with root permissions from time to time.
Ok, thanks. so i suppose pkexec nemo is safe? What about the warnings I get? Also not able to save folder order settings
User avatar
Pjotr
Level 23
Level 23
Posts: 19886
Joined: Mon Mar 07, 2011 10:18 am
Location: The Netherlands (Holland) 🇳🇱
Contact:

Re: Question about GUI and root?

Post by Pjotr »

Usually, in this case any warnings are innocent. So: what warnings?
Tip: 10 things to do after installing Linux Mint 21.3 Virginia
Keep your Linux Mint healthy: Avoid these 10 fatal mistakes
Twitter: twitter.com/easylinuxtips
All in all, horse sense simply makes sense.
billyswong
Level 8
Level 8
Posts: 2033
Joined: Wed Aug 14, 2019 1:02 am

Re: Question about GUI and root?

Post by billyswong »

"sudo" or "pkexec" is unnecessary for file browsers such as nemo/caja/thunar. The proper way is launch them normally, right click in their empty space, then "Open as Administrator" or "Open as Root".
User avatar
Jo-con-Ël
Level 11
Level 11
Posts: 3510
Joined: Sun Jun 20, 2021 12:41 pm
Location: donde habita el olvido

Re: Question about GUI and root?

Post by Jo-con-Ël »

Those are not warnings but errors, most probably related with gvfs/D-bus. See issue on github.
Last edited by Jo-con-Ël on Sun Feb 05, 2023 5:02 am, edited 2 times in total.
Arrieritos semos y en el camino nos encontraremos.
User avatar
ricardogroetaers
Level 6
Level 6
Posts: 1368
Joined: Sat Oct 27, 2018 3:06 am
Location: Rio de Janeiro, Brasil

Re: Question about GUI and root?

Post by ricardogroetaers »

Iridule wrote: Fri Feb 03, 2023 1:28 pm Sometimes I need to use nemo as root. I am using pkexec nemo Is this the correct way?
I don't know Nemo, I use Thunar.

I reasonably assume that Nemo, launched as a regular user, should have an option, in a context menu, to open a certain folder as root.

So I see no reason to run Nemo File Manager as root all the time.

Don't ask me about the engineering of the thing, because I don't know it.
In practice, without analyzing, demonstrating and explaining why:

pkexec is a "graphical prefix" (which unfortunately does not work with all programs) to launch "normally graphical" applications with privileges.
It must be placed, as a prefix, in the "command" field of the graphical launcher that launches the program.
It must not be invoked from a terminal window (command prompt).

See the example picture under XFCE to launch the "gnome-disks" program.
If I want to launch this graphical program with privileges, I put, in the "command field" of the launcher:
pkexec gnome-disks
The problem is that gnome-disks doesn't accept pkexec or pkexec doesn't work with gnome-disks.
Attachments
Captura de tela_2023-02-05_05-20-11.jpg
Last edited by ricardogroetaers on Sun Feb 05, 2023 5:44 am, edited 1 time in total.
User avatar
Pjotr
Level 23
Level 23
Posts: 19886
Joined: Mon Mar 07, 2011 10:18 am
Location: The Netherlands (Holland) 🇳🇱
Contact:

Re: Question about GUI and root?

Post by Pjotr »

ricardogroetaers wrote: Sun Feb 05, 2023 4:09 am pkexec is a "graphical prefix" (which unfortunately does not work with all programs) to launch "normally graphical" applications with privileges.
It must be placed, as a prefix, in the "command" field of the graphical launcher that launches the program.
It must not be invoked from a terminal window (command prompt).
It's quite alright to launch a graphical application with pkexec from a terminal window. No problem at all. :)
Tip: 10 things to do after installing Linux Mint 21.3 Virginia
Keep your Linux Mint healthy: Avoid these 10 fatal mistakes
Twitter: twitter.com/easylinuxtips
All in all, horse sense simply makes sense.
User avatar
ricardogroetaers
Level 6
Level 6
Posts: 1368
Joined: Sat Oct 27, 2018 3:06 am
Location: Rio de Janeiro, Brasil

Re: Question about GUI and root?

Post by ricardogroetaers »

Pjotr wrote: Sun Feb 05, 2023 5:10 am It's quite alright to launch a graphical application with pkexec from a terminal window. No problem at all. :)
It may work, but it will hold that terminal window until we close the program.
User avatar
Pjotr
Level 23
Level 23
Posts: 19886
Joined: Mon Mar 07, 2011 10:18 am
Location: The Netherlands (Holland) 🇳🇱
Contact:

Re: Question about GUI and root?

Post by Pjotr »

ricardogroetaers wrote: Sun Feb 05, 2023 5:49 am
Pjotr wrote: Sun Feb 05, 2023 5:10 am It's quite alright to launch a graphical application with pkexec from a terminal window. No problem at all. :)
It may work, but it will hold that terminal window until we close the program.
Yes, that's true. The terminal remains in charge. Closing the terminal window will also close the application. But that's only a cosmetic "problem"....
Tip: 10 things to do after installing Linux Mint 21.3 Virginia
Keep your Linux Mint healthy: Avoid these 10 fatal mistakes
Twitter: twitter.com/easylinuxtips
All in all, horse sense simply makes sense.
t42
Level 11
Level 11
Posts: 3709
Joined: Mon Jan 20, 2014 6:48 pm

Re: Question about GUI and root?

Post by t42 »

Pjotr wrote: Sun Feb 05, 2023 5:58 am The terminal remains in charge. Closing the terminal window will also close the application.
Not exactly. Using & operator

Code: Select all

pkexec nemo &
will opens nemo in background, providing nemo PID and leaving the terminal free to run commands.
You can close the terminal and nemo will remain running. Or you can press control+C and type your commands in terminal, or even type command without sending SIGINT (see free below):

Code: Select all

┌──(mf㉿D12T7)-[~]
└─$ pkexec nemo &
[1] 11588
┌──(mf㉿D12T7)-[~]
└─$ 
(nemo:11588): GLib-GIO-CRITICAL **: 11:42:20.884: g_dbus_interface_skeleton_export: assertion 'G_IS_DBUS_CONNECTION (connection)' failed

** (nemo:11588): WARNING **: 11:42:20.889: Current gtk theme is not known to have nemo support (Menta) - checking...

(nemo:11588): dconf-WARNING **: 11:42:21.173: failed to commit changes to dconf: Failed to execute child process ?dbus-launch? (No such file or directory)

(nemo:11588): dconf-WARNING **: 11:42:21.174: failed to commit changes to dconf: Failed to execute child process ?dbus-launch? (No such file or directory)
ERROR SET META:15 Setting attribute metadata::nemo-icon-view-auto-layout not supported
free
               total        used        free      shared  buff/cache   available
Mem:         8043832     1739216     3155168      389724     3149448     5648592
Swap:              0           0           0
┌──(mf㉿D12T7)-[~]
└─$ 
-=t42=-
User avatar
Pjotr
Level 23
Level 23
Posts: 19886
Joined: Mon Mar 07, 2011 10:18 am
Location: The Netherlands (Holland) 🇳🇱
Contact:

Re: Question about GUI and root?

Post by Pjotr »

t42 wrote: Sun Feb 05, 2023 6:56 am
Pjotr wrote: Sun Feb 05, 2023 5:58 am The terminal remains in charge. Closing the terminal window will also close the application.
Not exactly. Using & operator

Code: Select all

pkexec nemo &
will opens nemo in background, providing nemo PID and leaving the terminal free to run commands.
Nice!
Tip: 10 things to do after installing Linux Mint 21.3 Virginia
Keep your Linux Mint healthy: Avoid these 10 fatal mistakes
Twitter: twitter.com/easylinuxtips
All in all, horse sense simply makes sense.
User avatar
Bleys
Level 4
Level 4
Posts: 426
Joined: Wed Apr 20, 2022 4:17 am
Location: Essen, Germany

Re: Question about GUI and root?

Post by Bleys »

Pjotr wrote: Sun Feb 05, 2023 7:43 am
Not exactly. Using & operator

Code: Select all

pkexec nemo &
will opens nemo in background, providing nemo PID and leaving the terminal free to run commands.

Nice!
and with

Code: Select all

pkexec nemo & disown
you can close the terminal after the nemo start.
Ryzen 5 5600G, 16GB RAM, 2TB M.2 Crucial P3, Asrock Deskmeet X300, Samsung Odyssey 49", Linux Mint 21
User avatar
Pjotr
Level 23
Level 23
Posts: 19886
Joined: Mon Mar 07, 2011 10:18 am
Location: The Netherlands (Holland) 🇳🇱
Contact:

Re: Question about GUI and root?

Post by Pjotr »

Bleys wrote: Sun Feb 05, 2023 11:56 am
Pjotr wrote: Sun Feb 05, 2023 7:43 am
Not exactly. Using & operator

Code: Select all

pkexec nemo &
will opens nemo in background, providing nemo PID and leaving the terminal free to run commands.

Nice!
and with

Code: Select all

pkexec nemo & disown
you can close the terminal after the nemo start.
Noch schöner! :mrgreen:
Tip: 10 things to do after installing Linux Mint 21.3 Virginia
Keep your Linux Mint healthy: Avoid these 10 fatal mistakes
Twitter: twitter.com/easylinuxtips
All in all, horse sense simply makes sense.
User avatar
Bleys
Level 4
Level 4
Posts: 426
Joined: Wed Apr 20, 2022 4:17 am
Location: Essen, Germany

Re: Question about GUI and root?

Post by Bleys »

Pjotr wrote: Sun Feb 05, 2023 12:02 pm Noch schöner! :mrgreen:
But the easiest way is still to activate the context entry "Open as Root" in the nemo settings. As I have already mention above...

Aber am einfachsten ist es immer noch in den nemo Einstellungen den Kontext Eintrag "Als Systemverwalter öffnen" zu aktivieren. Wie ich weiter oben schon mal geschrieben habe...
Ryzen 5 5600G, 16GB RAM, 2TB M.2 Crucial P3, Asrock Deskmeet X300, Samsung Odyssey 49", Linux Mint 21
Iridule
Level 1
Level 1
Posts: 4
Joined: Fri Feb 03, 2023 1:19 pm

Re: Question about GUI and root?

Post by Iridule »

Bleys wrote: Sun Feb 05, 2023 12:09 pm
Pjotr wrote: Sun Feb 05, 2023 12:02 pm Noch schöner! :mrgreen:
But the easiest way is still to activate the context entry "Open as Root" in the nemo settings. As I have already mention above...

Aber am einfachsten ist es immer noch in den nemo Einstellungen den Kontext Eintrag "Als Systemverwalter öffnen" zu aktivieren. Wie ich weiter oben schon mal geschrieben habe...
I realize It is much easier to open using context menu but is nice to know pkexec is safer to use than sudo nemo. Thanks everyone for their replies.
Locked

Return to “Beginner Questions”