Running Dolphin as root

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)
1 Like

What about that:

1 Like

The sudo looks superflous to me - it should work without it.

1 Like

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.

2 Likes

Thanks! That works perfectly: Added the line to a custom .desktop shortcut which I should be able to use whenever I need it.

If You place a file in a local bin directory with
“pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY $@”
Rename the file “gksu” and make it executable.
After a reboot you can use “gksu” anywhere.

FYI, gksu is provided by zensu. He’s using KDE and there’s already kdesu provided by kde-cli-tools, wouldn’t that work? I don’t use KDE, so not really sure.

I know there’s plenty of threads here and on the archived forum about running Dolphin as root.

1 Like

I’m not running kde and “zensu” is considered to be a hack by the developer and there is also “gksu” in the AUR.
The prefered method is to use “pkexec” I believe, but it does not work on its own!

It’s hard to accept - is this actually right? - so many discussions in the last year about running Dolphin as root being a bad policy and also not being necessary…

I used to root Nemo to move themes and wallpapers around a lot when I used Mint.

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-plugins kde-servicemenus-rootactions installed should also be sufficient (iirc).

2 Likes

My apologies.
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…

2 Likes

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 :stuck_out_tongue: 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.

1 Like

Timeshift takes away that fear…
I use many ‘alias’ now that I don’t really need, they serve to remind me of stuff maybe that I only do every few months and then forget…

I’m just struggling now to remember (maybe 12 to 24 months ago) why I was so strenously arguing that I needed a root file browser and everyone was telling me to give up the bad habit.

I just haven’t used it for that long, I forgot now.

Don’t repeat that please… the man himself talks about a simple proof of concept attack against Dolphin.

Kate (as stated in my other post) is polkit-compliant, I’m surprised OpenSUSE does not support it, which explains how you didn’t know that.

https://doc.opensuse.org/documentation/leap/security/html/book.security/cha-security-policykit.html#sec-security-policykit-oview-authorizations

2 Likes

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.

nope, you can try it :wink:

you can do that with sudo nano /etc/default/grub or with sudo nano /etc/fstab without dolphin as root.

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.

1 Like

I just use Krusader the few times I feel the need to start a file manager as root. It’s handy when copying files to restricted locations.