I want to have a root privileges on some directories. How can I do this?
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.
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
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
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:
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
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:
You can do that in many ways:
Open nautilus as a root
You can add "Open as administrator" as an extension to your right click:
Download the nautilus-gksu package for your architecture from either of these 2 locations, and save it in your downloads folder.
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
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
sudo -H nautilus /path/to/folder/