This is as days pass by, by Stuart Langridge

And this is Editing files as root in Ubuntu, written , and concerning Rants, LazyWeb

When I right-click a file in Ubuntu and say “Open in gedit” or “Open in bluefish” or whatever, if I don’t have rights to edit that file, I don’t want it to open it read-only. Instead, I want it to say “You don’t have rights to edit this file? Open it read-only or edit it as root?” and then, if I pick “edit it as root“, do “gksudo “, so that I can edit it and don’t have to drop to a command line to do it.
How can I do this? The only way I can think of doing it is to change all my “open this file with this application” things so that, instead of opening the file in the app, it opens them with a little zenity shell script that does what I want. That’s a massive pain in the arse to do. The problem is that you can’t hack Nautilus to do this for you,. because it doesn’t want to happen with applications that aren’t editors. Suggestions, anyone?

Comments

Senji

Is it possible to do something along the lines of sticking a shim higher up on the PATH with the same name and tricking Nautilus into doing the right thing as a result?

who_me

Downlod KDE, then visit kde-look.org and obtain their “run as/open as/edit as” root service extensions. This gives you the above as part of a right click.

That wasn’t really helpful, sorry.

sil

sigh
I could do it myself by adding a script option to every file, but I don’t want to have to select myself whether to edit it as root or not. I want it to give me the option if it needs to, and not give me the option otherwise, not put a separate “edit this as…” option on everything’s menu.

Senji: I could do that, but then I’d have to have a shim per potential editor I wanted to use, which is nearly the same thing as writing a little shell script to do it and making that the edit action…

PeteG

Better yet, open it read only (maybe with a subtle warning flag) and then ask for root password if changes are made.

sil

PeteG: but that means hacking every potential editor. While I agree that your way is the best for usability, it’s also really hard to do, because applications don’t all save files by calling some OS save() function which I could change.

Jonas

Perhaps this may help:

http://ubuntuforums.org/showthread.php?p=116379

With this launcher it is very easy to open files as root. No hacking required.

joseph’s weblog

[...] http://www.kryogenix.org/days/2005/01/09/editing [...]

This website belongs to Stuart Langridge. Contact details are available. Don't eat yellow snow. Valid HTML5, at least in theory, except for the bits that aren't because I'm that futuristic that I'm ahead of the spec, oh yes. HTML5 help from Bruce Lawson, among others. Fonts from the superb FontSquirrel. End.