Open files with administrative privileges from the file manager

To open files with administrative privileges from the file manager, you need to add a script to Nautilus.

[Warning]

Opening files with administrative privileges is a security risk. Always ensure that you are familiar with the file that you are opening.

  1. Open a new file to edit in the relevant directory:

    gedit $HOME/.gnome2/nautilus-scripts/Open\ as\ Administrator

  2. Enter these lines in the new file:

    for uri in $NAUTILUS_SCRIPT_SELECTED_URIS; do
    gksudo "gnome-open $uri" &
    done
  3. Save the edited file (an example)

  4. Make the edited file executable:

    chmod +x $HOME/.gnome2/nautilus-scripts/Open\ as\ Administrator

You can now open a file as an administrator by right-clicking on it and choosing Scripts->Open as Administrator.