Page 8 of 9 FirstFirst ... 6789 LastLast
Results 71 to 80 of 88

Thread: HOWTO: Easily open any file as root via drag & drop

  1. #71
    Join Date
    Jun 2007
    Beans
    14,146

    Re: HOWTO: Easily open any file as root via drag & drop

    Only have jaunty on a live cd and for my hardy install actually prefer using nautilus actions instead for such activities

    This works fine on the live cd for both files and directories

    Code:
    #!/bin/sh
    for uri in $NAUTILUS_SCRIPT_SELECTED_URIS; do gksudo "gnome-open $uri" &
    done

  2. #72
    Join Date
    Nov 2007
    Location
    República de Tejas,Centro
    Beans
    232
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: HOWTO: Easily open any file as root via drag & drop

    Originally Posted by TurpoNieminen View Post
    Sorry im new to this so i ask stupid questions:
    Where i put this code?
    Some existing file or create new one? What directory?
    Quote Originally Posted by ariel View Post
    You have to create a new file in ~/.gnome2/nautilus-scripts, give it any name and put the above as content. Then set the "Allow executing file as program" using nautilus file properties.

    Then the name you chose should show up in right-click context menu when you select a file in nautilus, under "Scripts".

    However, the script above does not work in Jaunty / 9.04. I don't know why. If all you need is to edit the file as root, then this simpler script does work in 9.04:


    Code:
    #! /bin/sh
    # Usage:
    # 1) From Nautilus (assumes nautilus-scripts is setup): right-click on a single file, select the script link
    #
    
    gksudo gedit "$1"
    I'd rather use the more generic solution where gnome chooses the appropriate application based on the file type instead of hardcoding to gedit. I anyone can fix the original URI + gnome-open -based script that would be awesome. For some reason in all recent ubuntu versions the generic script stopped working.
    There was an update to the quoted (by TurpoNieminen) code about two or 3 pages back posted by JayTee & NobodySpecial HERE. The updated version changed to using "gksu" instead of "gnome-sudo" and this updated version works for me on Intrepid (v8.10):

    My 'open as root' file in ~/.gnome2/nautilus-scripts
    Code:
    #!/bin/sh
    ### openas-root:
    ###   nautilus script for opening the selected files as superuser (uid=0),
    ###   utilizing the appropriate applications.
    
    if [ -n "$1" ]; then
    for uri in $NAUTILUS_SCRIPT_SELECTED_URIS; do
            gksu "gnome-open $uri" &
    done
    else
    gksu "nautilus --no-desktop $NAUTILUS_SCRIPT_CURRENT_URI"
    fi
    PS: Thanx JayTee for the fix, NobodySpecial for updating the 'combo' script.
    Last edited by Skip Da Shu; May 20th, 2009 at 04:43 AM. Reason: add name link to earlier post
    - da shu @ HeliOS,
    "A child's exposure to technology should never be predicated on an ability to afford it."

  3. #73
    Join Date
    Nov 2007
    Location
    República de Tejas,Centro
    Beans
    232
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: HOWTO: Easily open any file as root via drag & drop

    BTW, Anybody know how to implement this in Xubuntu using Thunar?
    - da shu @ HeliOS,
    "A child's exposure to technology should never be predicated on an ability to afford it."

  4. #74
    Join Date
    Nov 2008
    Beans
    2

    Re: HOWTO: Easily open any file as root via drag & drop

    Excellent information, thanks to all who contributed.

  5. #75
    Join Date
    Aug 2007
    Location
    Scotland
    Beans
    72
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: HOWTO: Easily open any file as root via drag & drop

    Tried in 9.04, got......
    john@john-desktop:~$ gksudo "gnome-open %u"
    Error showing url: Error stating file '/home/john/%u': No such file or directory

    Any suggestions please

  6. #76
    Join Date
    Feb 2010
    Beans
    2

    Re: HOWTO: Easily open any file as root via drag & drop

    Quote Originally Posted by 23meg View Post
    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.

    Sorry im n00b as to Linux but I am guessing this will only work in GNOME, can it be adapted for xfce easily?

    Thanks

  7. #77
    Join Date
    Oct 2005
    Location
    Adelaide, South Australia
    Beans
    746
    Distro
    Ubuntu 11.10 Oneiric Ocelot

    Re: HOWTO: Easily open any file as root via drag & drop

    or you can just :
    Code:
    sudo apt-get install nautilus-gksu
    Fear is the mindkiller....
    The little death that obliterates...

  8. #78
    Join Date
    Feb 2010
    Beans
    2

    Re: HOWTO: Easily open any file as root via drag & drop

    Nautilus is some sort of file manager yes? What exactly is it for?

  9. #79
    Join Date
    Oct 2009
    Beans
    25

    Re: HOWTO: Easily open any file as root via drag & drop

    That is great, thanks for the tip.

    I have a related question. Sometimes I want to drag and drop a file into a protected location. For example, I am reimaging my machine and I have backed up (from the old machine), my /etc/hosts file, which contains host entries for various virtual machines I use as test/dev targets.

    Anyway, my user does not have privileges to copy files into /etc, so I would use sudo to perform that operation. (easy enough).

    When I try to drag and drop, using nautilus, from my backup file into the /etc folder, I am denied (of course). Is there a way to drag and drop in "sudo-mode", into a location that requires root authority?

    Thanks,

    Kevin

  10. #80
    Join Date
    Jun 2009
    Beans
    286

    Re: HOWTO: Easily open any file as root via drag & drop

    This has been an interesting thread, and while the original idea wasn't of particular use to me (sudo gedit works just fine), I like the idea of being able to copy a file to a restricted directory just by dragging it from another directory, as this approach potentially avoids dealing with long pathnames.

Page 8 of 9 FirstFirst ... 6789 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •