jeudi 8 janvier 2015

How to add "Open as Administrator " option on Ubuntu



How to add "Open as Administrator " option on Ubuntu :






Today im gonna show you in this simple tutorial how to add ‘Open As Root’ or ‘Open As Administrator’ option to context menu.Most users like to open files/folders as root directly from nautilus to do something with file-system and Nautilus offers ways to do that via extension or script.

There is many ways to add this option on Nautilus, but in this tutorial i picked up tree ways that works perfectly on Ubuntu 14.10/14.04/13.10/13.04/12.10/12.04 ,so let's start .



* Way n°1 :

- Script from Noobslab PPa :

For : Ubuntu 14.10/14.04/13.10/13.04/12.10/12.04/Linux Mint 17/16/15/14/13 

Copy / Paste the cmds bellow on a Terminal :
sudo add-apt-repository ppa:noobslab/apps
sudo apt-get update
sudo apt-get install open-as-administrator
After installing the script you should restart Nautilus :
nautilus -q
For : previous Nautilus version ( Nautilus 3.4.x ) :
cd && wget -O open-as-root.deb http://goo.gl/i25xqN
sudo dpkg -i open-as-root.deb
sudo apt-get -f install && rm open-as-root.deb

Now you could use "Open as Administrator" on Nautilus :


* Way n°2 : 

- Add the script manually :

In this way all you need to do is to copy / paste the script code bellow on gedit or any other text editor on Ubuntu. But before starting you should lookup for gksu ( Graphical Frontend to su ),gksu allows graphical programs to ask a user’s password to run program as root / administrator.

Open Ubuntu Software Center and search for gksu ( install it ) :


* Script code :

#!/bin/bash
#
# this code will determine exactly the path and the type of object,
# then it will decide use gedit or nautilus to open it by ROOT permission
#
# Determine the path
if [ -e -n $1 ]; then
obj="$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS"
else
base="`echo $NAUTILUS_SCRIPT_CURRENT_URI | cut -d'/' -f3- | sed 's/%20/ /g'`"
obj="$base/${1##*/}"
fi
# Determine the type and run as ROOT
if [ -f "$obj" ]; then
gksu gedit "$obj"
elif [ -d "$obj" ]; then
gksu nautilus "$obj"
fi

exit 0
Or download the script from here :  Open as root


Now after getting the script code you should copy it and paste it in this directory :

USER Home -> .local -> share -> nautilus -> scripts.

* ( Press Ctrl+H to view hidden files & folders )

Now open a terminal window and copy/paste the cmds bellow to make the script file executable :
cd .local/share/nautilus/scripts/ && chmod 0755 open-as-administrator
And restart Nautilus with : 
nautilus -q


* Way n°3 :

- Using "libnautilus-gksu.so" script :


In this way we gonna get the script and install it on two steps :

1)- Open a terminal window and copy/paste the cmds bellow :
wget http://www.liberiangeek.net/blog/tools/libnautilus-gksu.so
2)- Copy the file to " /usr/lib/nautilus/extensions-3.0 ":
sudo cp libnautilus-gksu.so /usr/lib/nautilus/extensions-3.0/


VIDEO TUTO :





That's all enjoy ;)

Share:

Popular Posts