"OPEN AS ROOT/ADMINSTRATOR" TO CONTEXT MENU FOR LINUX

Hi Everyone, This post is about How to open a folder as root without terminal.

Sometimes it is difficult to do in terminal so we have to do in GUI.

1. install gksu
 sudo apt-get install gksu  

 2. Open Nautilus file browser, press Ctrl+H to view hidden files & folders.
Navigate to USER Home - .local - share - nautilus - scripts.

3. create empty file named "open-as-root"

4. Open that file and paste this 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

5. Open your terminal open and paste this command
 cd .local/share/nautilus/scripts/ && chmod 0755 open-as-root

6. Finally restart Nautilus via command
 nautilus -q
or just log out and back in.

Here is the Youtube Video



Comments

Popular posts from this blog

How to Install Java JDK on Linux using terminal commands

INSTALLING SUBLIME TEXT 3 ON UBUNTU OR OTHER LINUX DISTROS

INFORMATION SECURITY

7 DOMAINS of IT

HOW TO INSTALL CISCO PACKET TRACER ON UBUNTU 16.04 LTS Or NEW Versions of Ubuntu