Ubuntu Forums ubuntu.com - launchpad.net - ubuntu help  

Go Back   Ubuntu Forums > The Ubuntu Forum Community > Other Community Discussions > Tutorials & Tips
Register Reset Password Forum Help Forum Council Search Today's Posts Mark Forums Read

Tutorials & Tips
The place to find Ubuntu related Tips & Tricks.

 
Thread Tools Display Modes
Old April 5th, 2005   #1
23meg
Ubuntu QA Team
 
Join Date: Mar 2005
Location: İstanbul
Beans: 5,882
Lightbulb HOWTO: Easily open any file as root via drag & drop

Create a launcher with the following command:

Code:
gksudo "gnome-open %u"
When you drag and drop any file on this launcher (it's useful to put it on the desktop or on a panel), it will be opened as root with its own associated application. This is helpful especially when you're editing config files owned by root, since they will be opened as read only by default with gedit, etc.
__________________
"Theoretically, a great number of ideas assures a great number of choices, but such choices are essentially quantitative. This practice is as bewildering as it is wasteful. It discourages spontaneity, encourages indifference, and more often than not produces results which are neither distinguished, interesting, nor effective. In short, good ideas rarely come in bunches." -- Paul Rand, The Politics of Design
23meg is offline   Reply With Quote
Old April 5th, 2005   #2
bored2k
Skinny Extra Sweet Ubuntu
 
bored2k's Avatar
 
Join Date: Feb 2005
My beans are hidden!
Re: HOWTO: Easily open any file as root via drag & drop

Very nice trick 23meg! very nice.
__________________
Sylvia: Look at what you've done to him!
Christof: I have given Truman the chance to lead a normal life. The world, the place you live in, is the sick place.
bored2k is offline   Reply With Quote
Old April 5th, 2005   #3
Buffalo Soldier
100% Pure Ubuntu
 
Buffalo Soldier's Avatar
 
Join Date: Nov 2004
Location: Kuala Lumpur, Malaysia
Beans: 884
Ubuntu 8.04 Hardy Heron
Send a message via MSN to Buffalo Soldier
Re: HOWTO: Easily open any file as root via drag & drop

So simple yet so easy and usefull. Wonder why no one has thought of it earlier. Should definitely be added to UbuntuGuide.org
Buffalo Soldier is offline   Reply With Quote
Old April 5th, 2005   #4
dare2dreamer
A Carafe of Ubuntu
 
Join Date: Oct 2004
Location: Dallas, TX
Beans: 111
Send a message via ICQ to dare2dreamer Send a message via AIM to dare2dreamer Send a message via MSN to dare2dreamer Send a message via Yahoo to dare2dreamer
Re: HOWTO: Easily open any file as root via drag & drop

Should be a trivial matter to work this up as a nautilus script, so it appears as an option in your right-click menu.

Call me silly, but an icon on my desktop that opens things as root just makes me nervous.
__________________
--dare2dreamer
dare2dreamer is offline   Reply With Quote
Old April 5th, 2005   #5
Nis
Gee! These Aren't Roasted!
 
Nis's Avatar
 
Join Date: Oct 2004
Location: Somewhere in Virginia
Beans: 173
Send a message via AIM to Nis
Re: HOWTO: Easily open any file as root via drag & drop

Quote:
Originally Posted by dare2dreamer
Should be a trivial matter to work this up as a nautilus script, so it appears as an option in your right-click menu.

Call me silly, but an icon on my desktop that opens things as root just makes me nervous.
As and you shall receive. Put the following into ~/.gnome2/nautilus-scripts/Open\ as\ root
Code:
#!/bin/sh
gksudo "gnome-open  $NAUTILUS_SCRIPT_SELECTED_URIS"
Then make it executable with
Code:
chmod +x ~/.gnome2/nautilus-scripts/Open\ as\ root
Nis is offline   Reply With Quote
Old April 5th, 2005   #6
Dracontopes
Gee! These Aren't Roasted!
 
Dracontopes's Avatar
 
Join Date: Oct 2004
Location: The Netherlands
Beans: 162
Ubuntu Breezy 5.10
Re: HOWTO: Easily open any file as root via drag & drop

Dude this is great! Nice job!
Dracontopes is offline   Reply With Quote
Old April 5th, 2005   #7
23meg
Ubuntu QA Team
 
Join Date: Mar 2005
Location: İstanbul
Beans: 5,882
Re: HOWTO: Easily open any file as root via drag & drop

yes that's better, thanks Nis. and thanks all for the kind words
__________________
"Theoretically, a great number of ideas assures a great number of choices, but such choices are essentially quantitative. This practice is as bewildering as it is wasteful. It discourages spontaneity, encourages indifference, and more often than not produces results which are neither distinguished, interesting, nor effective. In short, good ideas rarely come in bunches." -- Paul Rand, The Politics of Design
23meg is offline   Reply With Quote
Old April 6th, 2005   #8
dare2dreamer
A Carafe of Ubuntu
 
Join Date: Oct 2004
Location: Dallas, TX
Beans: 111
Send a message via ICQ to dare2dreamer Send a message via AIM to dare2dreamer Send a message via MSN to dare2dreamer Send a message via Yahoo to dare2dreamer
Re: HOWTO: Easily open any file as root via drag & drop

I love it when someone else does the work for me.

You might do a little error checking on the file names to make sure it doesn't hang up on filenames with spaces.

Either way, lovely hack.
__________________
--dare2dreamer
dare2dreamer is offline   Reply With Quote
Old April 6th, 2005   #9
Nis
Gee! These Aren't Roasted!
 
Nis's Avatar
 
Join Date: Oct 2004
Location: Somewhere in Virginia
Beans: 173
Send a message via AIM to Nis
Re: HOWTO: Easily open any file as root via drag & drop

Quote:
Originally Posted by dare2dreamer
I love it when someone else does the work for me.

You might do a little error checking on the file names to make sure it doesn't hang up on filenames with spaces.

Either way, lovely hack.
Already done. Passing the file as a URI (instead of just a filename) is already taken care of by Nautilus and gnome-open. I believe the spaces are replaced with "%20".
Nis is offline   Reply With Quote
Old April 6th, 2005   #10
maqi
A Carafe of Ubuntu
 
maqi's Avatar
 
Join Date: Mar 2005
Location: Brisbane, Australia
Beans: 105
Ubuntu 6.10 Edgy
Re: HOWTO: Easily open any file as root via drag & drop

This is excellent

Thanks 23meg and Nils. Life just got even easier

maqi
__________________
A Gentleman is one who can play the bagpipes, yet chooses not to.
maqi is offline   Reply With Quote

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 01:53 AM.


vBulletin ©2000 - 2010, Jelsoft Enterprises Ltd. Ubuntu Logo, Ubuntu and Canonical © Canonical Ltd. Tango Icons © Tango Desktop Project. bilberry