Welcome, Guest. Please login or register.
Did you miss your activation email?

Author Topic: [EN] [Solved] Open as root GUI applications  (Read 1658 times)

Offline Mte90

  • User
  • Posts: 221
  • KDE & Debian lover
    • http://www.mte90.net
[EN] [Solved] Open as root GUI applications
« on: 2024/01/22, 11:02:00 »
I want to able to run from console applications as root to simplify various things.

Right now with kde and GTK software I get that error:

Code: [Select]
mte90  /  home  mte90  partitionmanager
Invalid MIT-MAGIC-COOKIE-1 key
qt.qpa.xcb: could not connect to display :0
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, xcb.

Annullato (core dump creato)
 mte90  /  home  mte90  134  gprename
Invalid MIT-MAGIC-COOKIE-1 key

(gprename:30324): Gtk-WARNING **: 10:59:23.341: cannot open display: :0

I know that is not something safe but I know what I do in those cases.
Can you help me on fixing those errors?

I still using xorg right now.
« Last Edit: 2024/01/24, 14:40:21 by Mte90 »

Offline eriefisher

  • User
  • Posts: 266
Re: Open as root GUI applications
« Reply #1 on: 2024/01/22, 16:28:22 »
For graphical applications use pkexec to avoid errors.

Code: [Select]
pkexec application-name
You will be prompt for your password.

Offline Mte90

  • User
  • Posts: 221
  • KDE & Debian lover
    • http://www.mte90.net
Re: Open as root GUI applications
« Reply #2 on: 2024/01/22, 16:32:11 »
Nope, I am getting the same error as non-root when I try it:

Code: [Select]
mte90    Desktop  pkexec dolphin
qt.qpa.xcb: could not connect to display
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, xcb.

Annullato (core dump creato)

Offline scholle1

  • User
  • Posts: 86
Re: Open as root GUI applications
« Reply #3 on: 2024/01/22, 20:20:30 »
Did you try
Code: [Select]
su-to-root -X -c <application-name>or If error messages related to dbus occur, expand the input:
Code: [Select]
su-to-root -X -c 'dbus-launch <application-name>?
Also take a look at the manual '7.1.1 Work as root'.
I use XFCE. Maybe the behavior is different in KDE.
Je mehr Bürgerinnen und Bürger mit Zivilcourage ein Land hat, desto weniger Helden wird es einmal brauchen.
(Franka Magnani)

Offline eriefisher

  • User
  • Posts: 266
Re: Open as root GUI applications
« Reply #4 on: 2024/01/22, 21:45:26 »
I was searching you error and it seems to only come up while logged in via ssh remotely. Is this the case in your situation?

Offline Mte90

  • User
  • Posts: 221
  • KDE & Debian lover
    • http://www.mte90.net
Re: Open as root GUI applications
« Reply #5 on: 2024/01/23, 10:28:33 »
Thanks both,
so no I am trying root on my workstation with siducation not on SSH.

I tried "su-to-root -X -c 'dolphin'" as non-root user, opens a terminal to write the password, so for sure it is a workaround (I will add a new alias), but it will be handy to be able to launch GUI applications from the root user to avoid to write the password again.

Offline hendrikL

  • Administrator
  • User
  • *****
  • Gravatar
  • Posts: 933
Re: Open as root GUI applications
« Reply #6 on: 2024/01/23, 10:54:49 »
Strange, really strange, I am able to open dolphin as root, strange (I su - into root), don't know what I have done that this works.  8)
Code: [Select]
root@localhost:~# dolphin
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'

I rebooted several times, logged -out and -in, it works, here™, no joke!

I thought it was disabled long time ago because of safety reasons, there was a big discussion on that.

Code: [Select]
root@localhost:~# LANG=C partitionmanager
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
kf.coreaddons: "Could not find plugin kpmcore/"
Could not create instance of plugin   ""
Loaded backend plugin:  "pmsfdiskbackendplugin"
QWidget::setMinimumSize: (MessageWidgetDock/QDockWidget) Negative sizes (0,-1) are not possible
QWidget::setMaximumSize: (MessageWidgetDock/QDockWidget) Negative sizes (0,-1) are not possible
"Using backend plugin: pmsfdiskbackendplugin (1)"
"Scanning devices..."
"Device found: CT250MX500SSD1"
230399 139024 4096
unknown file system type  ""  on  "/dev/sda3"
14710672 4987186 4096
208127 54186 4096
5245439 2068991 4096
"Partition ‘/dev/sda4’ is not properly aligned (last sector: 120.407.174, modulo: 1.159)."
"Partition ‘/dev/sda5’ is not properly aligned (last sector: 391.761.088, modulo: 1.217)."
"Scan finished."


Works too!
« Last Edit: 2024/01/23, 10:59:45 by hendrikL »

Offline Mte90

  • User
  • Posts: 221
  • KDE & Debian lover
    • http://www.mte90.net
Re: Open as root GUI applications
« Reply #7 on: 2024/01/23, 11:13:06 »
I have this machine rolling since 2012 as I can remember so maybe something was messed up...

Maybe it is enough to set somewhere what is the display to use looking at the error I get.

Offline hendrikL

  • Administrator
  • User
  • *****
  • Gravatar
  • Posts: 933
Re: Open as root GUI applications
« Reply #8 on: 2024/01/23, 11:41:51 »
I have this machine rolling since 2012 as I can remember so maybe something was messed up...

Maybe it is enough to set somewhere what is the display to use looking at the error I get.

Your system behaves as it should, nothing wrong!

My™ system behaves strange, that what I am trying to say.

su-to-root I would recommend too, what also works is "doas" (should), see our manual.

https://manual.siduction.org/sys-admin-doas_en.html


On the other hand you can try another file manger like krusader or doublecmd and so on

Offline Mte90

  • User
  • Posts: 221
  • KDE & Debian lover
    • http://www.mte90.net
Re: Open as root GUI applications
« Reply #9 on: 2024/01/23, 11:47:54 »
Tested now doas following the wiki and works too.

I only sad that as root user I am not able to run any GUI , maybe it is something to configure on xorg or a environment variable?

Offline ro_sid

  • User
  • Posts: 223
Re: Open as root GUI applications
« Reply #10 on: 2024/01/23, 14:19:14 »
Tested now doas following the wiki and works too.

I only sad that as root user I am not able to run any GUI , maybe it is something to configure on xorg or a environment variable?
I am not on Siduction at the moment, but will look it up later on. The problem could/should be, that you do not have the "Xauthority" "MIT-MAGIC-COOKIE" to access the user's X-Display. You must provide that (temporary and local) cookie for the root-user, too.
Normally, even with Siduction, this is handled automatically, when you open a terminal (within X11!) as user and then su/sudo/doas from there.
The cookie used to be in a user's homedirectory in an .xauth- (or was it .Xauth-?) file, Ubuntu does it via gdm in /run/user/"userid"/gdm/Xauthority and I guess, KDE-Siduction will do it in a similar sddm-file, but as written, I have to look this up, later, sorry.

Offline Mte90

  • User
  • Posts: 221
  • KDE & Debian lover
    • http://www.mte90.net
Re: Open as root GUI applications
« Reply #11 on: 2024/01/23, 14:58:54 »
I have the file /home/mte90/.Xauthority maybe it's enough to do a symlynk in the /root/ folder to access the xorg environment?

Offline ro_sid

  • User
  • Posts: 223
Re: Open as root GUI applications
« Reply #12 on: 2024/01/23, 17:33:35 »
I have the file /home/mte90/.Xauthority maybe it's enough to do a symlynk in the /root/ folder to access the xorg environment?
You may try, it should not do any harm. But since I do not know, when .Xauthority gets removed or if it will just be replaced at next login,
you may experience a "dangling symlink" sometimes eventually.

Offline Mte90

  • User
  • Posts: 221
  • KDE & Debian lover
    • http://www.mte90.net
Re: Open as root GUI applications
« Reply #13 on: 2024/01/23, 17:37:48 »
Uhm on the root user I see the same file that is a symlink:

Code: [Select]
lrwxrwxrwx      -         - root root  13 lug  2020  .Xauthority -> /var/run/xauth/*
That doesn't exists, this can explain a bit what is happening.

So now:
Code: [Select]
lrwxrwxrwx      -         - root root  23 gen 17:38  .Xauthority -> /home/mte90/.Xauthority
But I am getting the same error, maybe I need to reboot to test it.

Offline ro_sid

  • User
  • Posts: 223
Re: Open as root GUI applications
« Reply #14 on: 2024/01/23, 23:43:03 »
As promised, now on Siduction, I can report my situation there (with working "root"-X11-programs). It is the display-manager, which creates the "master"-authfile in /run/sddm/ (sddm is the display-manager for KDE-siduction). "root" automatically gets "copies" of it - several in my case - in its home as .xauth... with ... being uniqe endings. I assume, that the terminal(s) (automatically) generate them, when doing su/sudo/doas. It also seems important, that only the corresponding user has access to them (rw-------).
In my case, there is no .Xauthority file in root's home (/root).