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

Ubuntu 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

10 comments

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

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

    • @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.

  3. 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.

  4. 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

Comments are closed.

Sponsored Stories