Opening XTerm with root privileges from Q menu

Hello,

The minimal termplates come with xterm but not passwordless sudo. My current approach is to avoid installing passwordless sudo, by typing

qvm-run -u root QUBE_NAME xterm

into dom0.

This is fine for me, but I also want to create a guide for non-experts, which means that being able to do things via the GUI will help a lot

To this end, I’ve tried creating a .desktop entry in debian-12-minimal. Like so:

# Create the .desktop file with full metadata
sudo tee "$DESKTOP_FILE" > /dev/null <<EOF
# This file was generated to provide a root xterm entry in Qubes
[Desktop Entry]
Name=XTerm (Root)
Comment=Run xterm as root using qvm-run
Exec=qvm-run -u root debian-12-minimal xterm
Terminal=false
Type=Application
Icon=mini.xterm
Categories=System;TerminalEmulator;
Keywords=shell;prompt;command;commandline;cmd;
StartupWMClass=XTerm
X-Desktop-File-Install-Version=0.26
EOF

Unfortunately, the resulting Q-menu entry doesn’t work.

Ideas, anyone?

There are multiple solutions to your requirement.

  1. Take a look at ~/.local/share/applications (in dom0) and find .desktop file for Debian 12 Xterm (it should be something like org.qubes-os.vm._debian_d13_dminimal.debian-xterm.desktop. Then copy the file to a new .desktop file. Modify these two lines:
--- org.qubes-os.vm._debian_d13_dminimal.debian-xterm.desktop	2025-07-21 14:07:48.520426875 +0330
+++ org.qubes-os.vm._debian_d13_dminimal.debian-xterm2.desktop	2025-07-30 12:36:14.032578663 +0330
@@ -5,9 +5,9 @@
 X-Qubes-VmName=debian-13-minimal
 X-Qubes-AppName=debian-xterm
 Icon=/home/alimirjamali/.local/share/qubes-appmenus/debian-13-minimal/apps.icons/debian-xterm.png
-Name=debian-13-minimal: XTerm
+Name=debian-13-minimal: XTerm (root)
 StartupWMClass=debian-13-minimal:XTerm
 Comment=standard terminal emulator for the X window system
 Categories=System;TerminalEmulator;X-Qubes-VM;
-Exec=qvm-run -q -a --service -- debian-13-minimal qubes.StartApp+debian-xterm
+Exec=qvm-run -q -a --service -u root -- debian-13-minimal qubes.StartApp+debian-xterm
 X-Qubes-DispvmExec=qvm-run -q -a --service --dispvm=debian-13-minimal -- qubes.StartApp+debian-xterm

Pay attention that it uses qubes.StartApp+debian-xterm.
Then you will have the root shortcut in App Menu which will work:

  1. There has been a recent patch to Qui Domains Widget (I am not certain if it is only available for Qubes OS r4.3 or is backported to r4.2 as well). If you hold down shift key and point you mouse to Run Terminal menu item, it morphs to Run Root Terminal and you will be able to open root terminal directly from there.

  2. If you want similar behavior from App Menu shortcuts (allowing to run them as root while holding shift key), you may open a feature request on Qubes Github issues page.

3 Likes

And if you’ve put it within the template itself and not dom0, that won’t work.

This is phenomenal. Works in r4.3 testing and is a really nice, almost hidden, feature. Hoping the release notes go into great detail about all the latest improvements as I would have missed this were it not for your note.

1 Like

BTW, the Debug Console in that screenshot is enabled by setting expert-mode feature (for dom0 for all qubes or for individual qubes). it is usually good for GUI-less qubes and/or headless qubes. Or debugging qubes with broken GUI.

1 Like

Is that just qvm-prefs dom0 expert-mode 1?

I use the qvm-run ... -u root ... xterm command too, but I’m wondering … wouldn’t it be better to use qvm-console-dispvm (avoiding running graphical applications with root)?

2 Likes

No. It is qvm-features dom0 expert-mode 1

Both have their advantages and merits. For example the console could be used with headless (GUI-less) qubes. For example mirage. Whereas you could launch a graphical program from xterm.