There are cases when it’s necessary to open the Dolphin file manager as root, to edit OS files my user account doesn’t normally have access to. I only do this when necessary and yes I’m aware of the dangers… never broke anything in a decade this way so it’s all good.
On openSUSE there’s a default shortcut to launch Dolphin as root, using the command dbus-launch dolphin -qwindowtitle "%c" "%u": I tried this in Manjaro but it causes Dolphin to open normally there. Manjaro doesn’t offer a builtin method so I currently I have no way of doing this. I found an article suggesting I use use pkexec dolphin however this fails to launch with the following error:
[mircea@mircea-virtualbox ~]$ 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.
Aborted (core dumped)
I found and installed a package called kde-servicemenus-rootactions from the repositories. It adds a menu in normal dolphin to open a directory under root dolphin. For some reason this doesn’t work though, clicking the new option does nothing. I may have to use that addon, thanks for sharing.
It’s a rare scenario which should be minimized as much as possible. I typically only use Dolphin as root to edit the grub2 boot parameters, or fstab if I add or remove a hard drive in a planned manner; It’s easier to click on the file and have it open in Kate / KWrite than editing from the console.
Just fyi as a user you do have access opening those files and editing with kate. Then kate will ask for a root password the moment you try to save it. It’s all under polkit rules. There’s absolutely no reason giving rights to X11, it’s not about breaking stuff but about security. For copying and moving files having the package dolphin-pluginskde-servicemenus-rootactions installed should also be sufficient (iirc).
I fail to see how it is important to use Dolphin as root to edit fstab…
It is clearly MUCH simpler and shorter (if you want kate) to hit alt+Space and type kate /etc/fstab or if you want code, type code /etc/fstab or to open terminal and do micro /etc/fstab.
Also (personally) if I want to remount a drive in a controlled way, but are firmly glued into the Windows thinking of ‘must use clicky GUI’ then use gnome-disks because it can’t mess up writing your fstab and rendering your installation borked.
If you’re sensible, and you want to fix a permanent disk mount, then use systemd to do it.
You should not use root permissions for Dolphin - it’s just wrong. You do NOT need to run a root browser to go to your grub.
Try in krunner now: dolphin /etc/default/ There, add that as a bookmark. Remember, you can also make an alias 'editgrub=‘code /etc/default/grub’ too.
That’ll work in terminal, if you want to learn and remember this stuff, then you launch terminal and type ‘alias’ to get a full list of all the stuff you want to remember.
Kate, or code are both great - and behave properly and only elevate permissions when you want to overwrite the root file.
Once again, you DO NOT NEED to run Dolphin as root. These are bad habits picked up running Ubuntu in 2007… move along please people.
However, if there IS a need - you can always pkexec thunar to get a root browser. I forgot I’d even installed that… comes in useful if you want to brutishly do stuff between your /home folder and another (I have test user to help troubleshooting)
I find thunar works best with tiling mode set - as it isn’t a dual pane browser… it does have the handy-dandy tree mode too.
Though for most stuff - just use Dolphin, not as root…
Good thoughts to be aware of. I also didn’t know until now that Kate has its own system to deal with overwriting root files when ran as an user, this makes such edits a lot easier.
I never used Ubuntu: Picked up this habit from openSUSE. It’s not something anyone ever advised me to do, I just found it easier and got used to it on my own If you run a single-user system, the only risk of playing with this is breaking your system and having to do a fresh install… for me the risk of accidentally deleting important data I didn’t backup from my home directory is scarier nowadays.
That gives a lot of depth into it, I admit it’s an aspect I never thought about. Yes, X11 is insecure and allows that sort of thing. This will hopefully be fixed by Wayland… which I can’t use because KDE / Plasma is yet to properly support it without something crashing the session every 10 minutes alongside graphical glitches at every corner.
And openSUSE does install Kate by default. I just never used it especially to edit root files, hence why I didn’t know it has this ability… most likely this works on openSUSE as well.
Well yes, but some folks don’t like the terminal so much - nano or vim… that’s why I mentioned ‘micro’ which is the example in my screenshot - also showing how the styling is dropped when running as root and really giving no benefit other than doing it the wrong way…
I’ll admint, after years of running stuff as root, I wasn’t happy to be told it’s all wrong - it was Dalto that started ripping into me, and Kresmir was rolling his eyes at the stupidity of my determination to keep doing it the old way…
I came up with examples off the top of my head, like moving wallpapers and themes to /usr/share/ folders but the truth is that I haven’t used a root browser in the last 2 years, despite messing with my Grub and other system files.
Partly the point here is that Linux must move forward, people must unlearn old bad habits. There are many improvements to be made, truth be known, and the insistence of applications to refuse to be run as root is an important step.
I understand the counterpoint - I don’t care much either, I can install and restore a snapshot in 15 minutes, so who cares?
However, when you do it the right way, it just feels so much better.