Ubuntu: Easy (And Quick) Ways To Open Any Files As Root

root-privilege.jpgUbuntu does not allow its users to login as root directly. For users who want to run programs (or edit files) with root privileges, they have to use “sudo” to allow access to root. While this is a very useful feature to protect your system, it can be a troublesome and repetitive task.

Instead of hitting the terminal and enter the ‘sudo‘ command everytime you need to open a file with root privilege, you can use any of the following methods to easily access your files with a mouse click.

1) Create a gksudo Launcher

  • Right-click unused space in either the top or bottom panel.
  • Choose “Add To Panel…”
  • Choose Custom Application Launcher
  • In the window that pops up, enter the following:
    Name: GKSudo launcher
    Command: gksudo “gnome-open %u”
    Comment: Open files with root privilege
  • Click the No Icon button to select an icon for your launcher.
  • Click OK

Your Gksudo launcher should now appear on the panel.

Now, to open a file with root privilege, just drag and drop the file to this launcher.

2) Install ‘nautilus-gksu’

Install ‘nautilus-gksu‘ via the Synaptic Package Manager. Now when you right click on any files or folder, you can see the option “Open as administrator“.

3) Use nautilus-script

If for some reason, you can’t install the ‘nautilus-gksu‘, you can achieve the same function via creating a nautilus script manually.

In the terminal,

gedit $HOME/.gnome2/nautilus-scripts/Open\ as\ Administrator

Insert the following lines into the new file:

for uri in $NAUTILUS_SCRIPT_SELECTED_URIS; do gksudo “gnome-open $uri” & done

Save the file.

Make the file executable:

chmod +x $HOME/.gnome2/nautilus-scripts/Open\ as\ Administrator

You can now open files as root by right clicking on the file and selecting Scripts->Open as Administrator

  • Tasos

    If you used KDE, you would know that you dont have to all this because Konqueror has this installed by default.

  • Tasos

    If you used KDE, you would know that you dont have to all this because Konqueror has this installed by default.

  • anonymous coward

    To do the same thing in kde:
    Left click desktop> create new…>link to application>
    Put kdesu konqueror for a root privileged file browsing window. kdesu ….. for whatever root app you want.

  • anonymous coward

    To do the same thing in kde:
    Left click desktop> create new…>link to application>
    Put kdesu konqueror for a root privileged file browsing window. kdesu ….. for whatever root app you want.

  • bahh

    Is there nothing that is easy in Linux. This OS SUCKS. I cant believe I actually fell for it and wasted 3 dam days.

    • http://salamanteri.homelinux.net/wordpress/ robsku

      @bahh
      Option 2: Install ‘nautilus-gksu’

      Sooo… what is it exactly that seems so hard to you? Can’t get much easyer, huh?

      This kinda smells like troll really, unless you accidentally missed option two (numbers 1 and 3 are not exactly rocket science either but nobody can claim that option two is not easy.

  • bahh

    Is there nothing that is easy in Linux. This OS SUCKS. I cant believe I actually fell for it and wasted 3 dam days.

    • http://salamanteri.homelinux.net/wordpress/ robsku

      @bahh
      Option 2: Install ‘nautilus-gksu’

      Sooo… what is it exactly that seems so hard to you? Can’t get much easyer, huh?

      This kinda smells like troll really, unless you accidentally missed option two (numbers 1 and 3 are not exactly rocket science either but nobody can claim that option two is not easy.

  • Placebo

    Thanks for the help man! You really saved me from having to refer to the terminal every time I need to edit and move files.

  • Placebo

    Thanks for the help man! You really saved me from having to refer to the terminal every time I need to edit and move files.

  • heyjohnreese

    Great tips, Ive been looking for an easier way to edit root files. Thanks!

  • heyjohnreese

    Great tips, Ive been looking for an easier way to edit root files. Thanks!

  • stari veselin

    Thanks, this helped!

  • stari veselin

    Thanks, this helped!

  • Pingback: Modifying the toolbar of Planner under Ubuntu - text_zinaf

  • http://sikku.blogspot.com/ Sikku

    How to use this in Fedora with gnome destkop???

    • http://maketecheasier.com/ Damien

      I am not really proficient in Fedora, so I can’t be of any help in this.

  • http://sikku.blogspot.com/ Sikku

    How to use this in Fedora with gnome destkop???

    • http://maketecheasier.com Damien

      I am not really proficient in Fedora, so I can’t be of any help in this.

  • http://tricountyreo.com/ Jamal

    Thanks for this bro, really helped me out!

  • http://tricountyreo.com Jamal

    Thanks for this bro, really helped me out!

  • Pingback: Tweets that mention Ubuntu: Easy (And Quick) Ways To Open Any Files As Root – Make Tech Easier -- Topsy.com

  • http://twitter.com/actualmanx Kieran Hill

    Thank you for this
    You did it this way Name: GKSudo launcher
    Command: gksudo “gnome-open %u”
    Comment: Open files with root privilege

    im on ubuntu 10.04 i did it with gksudo gnome-terminal
    it would not work with your gksudo “gnome-open %u”
    hope this helps others

Use left/right keys to browse stories.