Is it possible to open directories as administrator?

Solution 1:

Create a simple nautilus script can also open a folder as root.

#!/bin/bash
gksudo nautilus $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS

Save the above script as Open folder as root in your ~/.gnome2/nautilus-scripts/. On right click you will have an option under scripts, Open folder as root. And you can open a folder as root after providing your root password.

Do not forget to give the script execution permission. You can use in terminal,

chmod +x ~/.gnome2/nautilus-scripts/Open\ folder\ as\ root

Or you can right click on the file, then go to Properties >> Permissions and check the box corresponds to Execute to give the script execution permission.

enter image description here

enter image description here

To use gksudo you need to install gksu. In Ubuntu 13.04 onwards it is not install by default. You can install it using,

sudo apt-get install gksu

Open files and folders as root

There is a nice application xdg-open which can open any arbitrary file or URL in the user's preferred application. One can replace nautilus with xdg-open in the above script and it will enable one to open folders as well as all files as root.[Proposed by Sadi] It increases the applicability of the code. The modified script will look like,

#!/bin/bash
# script_name: open as root
gksudo xdg-open $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS

Solution 2:

My solution is to add an option for “Open as Administrator” to directories.

As you can see, there is no “Open as Administrator” option when you right click on a folder:

Screenshot of right-click menu

First, add the package repository by opening your Terminal and typing:

$ sudo add-apt-repository ppa:noobslab/apps

A message will appear:

You are about to add the following PPA to your system:
 This PPA Contains Applications for Ubuntu/Linux Mint from different sources but debianized by http://www.NoobsLab.com
 More info: https://launchpad.net/~noobslab/+archive/apps
Press [ENTER] to continue or ctrl-c to cancel adding it

Press Enter.

Now we’ve added the repository, it’s time to update our sources:

$ sudo apt-get update

After you update, it’s time to install the package we want for our issue:

$ sudo apt-get install open-as-administrator

Finally, you should restart Nautilus:

$ nautilus -q

And now the “Open as Administrator” option should appear:

Screenshot of right-click menu

Solution 3:

You can do that in many ways:

  • Log in as root

  • Open nautilus as a root

    gksu nautilus
    
  • You can add "Open as administrator" as an extension to your right click:

    1. Download the nautilus-gksu package for your architecture from either of these 2 locations, and save it in your downloads folder.

      32 bit: Direct link from ubuntu.mirror.cambrium.nl

      64 bit: Direct link from ubuntu.mirror.cambrium.nl

    2. On your 64 bit install downloaded nautilus-gksu_2.0.2-5ubuntu2_amd64.deb & extracted right in your Downloads folder

      sudo cp ~/Downloads/nautilus-gksu_2.0.2-5ubuntu2_amd64/usr/lib/nautilus/extensions-2.0/libnautilus-gksu.so /usr/lib/nautilus/extensions-3.0
      
    3. On your 32 bit install downloaded nautilus-gksu_2.0.2-5ubuntu2_i386.deb & again extracted in Downloads folder so terminal command

      sudo cp ~/Downloads/nautilus-gksu_2.0.2-5ubuntu2_i386/usr/lib/nautilus/extensions-2.0/libnautilus-gksu.so /usr/lib/nautilus/extensions-3.0