Editing files as root in Ubuntu
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
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?
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?
2 hours later
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.
6 hours later
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…
8 hours later
Better yet, open it read only (maybe with a subtle warning flag) and then ask for root password if changes are made.
12 weeks later
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.
12 weeks later
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.
53 weeks later
[...] http://www.kryogenix.org/days/2005/01/09/editing [...]
160 weeks later