Using a GUI File Browser with sudo

Asked by RogerB on 2008-08-21

Hello,

So here I am wanting to pick a file out of Nautilus and edit it, then save. It’s a file with RW only for owner (root) and read-only for group and others. Of course root is locked and I’m logged in as little ‘ol me, albeit with root privileges.

If I did this from the command line I’d do something like ‘sudo vi <file>’ I guess…or I could change the attributes of the file before I edit it.

Can I make this a little more seamless so I can pick a file out of a GUI file browser, like Nautilus, edit it and save as if I were root (sudo)? I know I can launch an editor with ‘gksudo gedit’ too….

System details:
Ubuntu Rel 8.04(Hardy)
Kernel Linux 2.6.24-19-server
Gnome 2.22.3

Tnx,
Roger

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu nautilus Edit question
Assignee:
No assignee Edit question
Solved by:
Andrew
Solved:
2008-08-22
Last query:
2008-08-22
Last reply:
2008-08-22
Best Andrew (and471) said : #1

Well you can launch nautilus (the file manager) as root by using

sudo nautilus

If thats what you were thinking. If not, you may want to look on the nautilus scripts site, to see if there are any on there that meet your requirements

http://g-scripts.sourceforge.net/

RogerB (mrbonuchi) said : #2

Thanks for your quick reply rugby471...That's fine, but can you tell me how to edit the startup properties for a menu item? For example, the "file browser" icon for Nautilus in my Ubuntu drop-down menu starts the Nautilus app...how can I edit the startup cmdline to do 'sudo nautilus'? I've looked but can't find that property.

Tnx, Roger

RogerB (mrbonuchi) said : #3

UPDATE - I found that I could copy a menu item to the desktop, Nautilus in this case, then I could edit the properties to start Nautilus with ´gksudo gedit %U´. That lets me save a file that is only writable by root. (what I wanted). This is simple stuff of course, but not for a new Ubuntu user.

So, when I pick a file (double-click to open) out of the file browser, I don't get Nautilus with the cmdline I put on the desktop...of course...so how do I get the default launch of Nautilus to use ´gksudo gedit %U´?

thanks in advance,
-Roger

Andrew (and471) said : #4

Hmm.. I wouldn't Advise that you use nautilus in root mode all the time, that is a very unsafe way to go about it.

May I ask just why you wish to always have it in root mode (and which files oyu contstantly need to edit) so I can have a better understanding?

RogerB (mrbonuchi) said : #5

You make a good point. I don’t use this machine for a common desktop, it’s a web server for light-duty use. I find myself only editing files for configs, etc.

I’ll take your advice and run Nautilus in sudo mode only when need be.

Thanks for your help, much appreciated.

-Roger

RogerB (mrbonuchi) said : #6

Thanks rugby471, that solved my question.

Andrew (and471) said : #7

That's fine, i'm glad your problem is now solved!

NOTE:If all you need to do is edit text files in root mode, the forum post below has a script to open a file in nautilus as root with gedit

http://ubuntuforums.org/showthread.php?t=47525