Linux – How to open files as root via a right click

The following tutorial explains how to add a context menu item that enables a Linux user to open files as the root user when browsing their filesystem using nautilus.

This [gs script] feature allows the user to navigate their file system and open or edit any file or directory as the root user of the system. It's a perfect solution for those that are not completely comfortable using terminal commands.

NOTE: This tutorial assumes your using a Debian based system utilizing Gnome and nautilus. Systems such as Ubuntu or another Debian based derivative. The Ubuntu Live CD was used for this tutorial. Your"$Home/.gnome2" path may vary. In addition, if your attempting this on a Full Blown Debian installation, you will first need to make sure your user has been added to the sudoers list.

Adding a contextual menu item to open as root

  1. Open a [gs terminal] and type sudo su
  2. Then type the following:
    gedit .gnome2/nautilus-scripts/Open\ as\ root
  3. Now add the following to the open document and save the file:
    for uri in $NAUTILUS_SCRIPT_SELECTED_URIS; do
    gksudo "gnome-open $uri" &
    done
  4. Back at the [gs terminal], type:
    sudo chmod +x .gnome2/nautilus-scripts/Open\ as\ root

All set, now when you want to open a file as root, simply right click the file and select Scripts-> Open as root

NOTE: You may need to restart to see the changes!

Right Click open as root Screenshot

SOURCE

LINK (Pendrivelinux.com)

LANGUAGE
ENGLISH