Add ‘Open as Administrator’ to Pantheon in Elementary OS Luna

Last updated: October 7, 2013

This simple tutorial will show you how to add ‘Open as Administrator’ or ‘Open as root’ to Pantheon Context menu in Elementary OS Luna. So that you can easily open system files or folders with super user privilege through the default Pantheon file browser.

First take a look at the screenshots:

open file as root in elementary os

open file as root in elementary os

open folder as root in elementary os

Before getting started, search for and install gksu from Software Center. It is a Gtk+ frontend allows graphical programs to ask a user’s password to run another program as root / administrator.

Open files as root in Panthen Context Menu:

It’s a little different to Ubuntu Nautilus. Because I don’t know how to use if conditional statements in ‘.contractor’ files, so I divided this into two parts: Open files as root and Open folders as root.

1. Use your favorite editor to create and edit the config file. Here I use gedit (press Ctrl+Alt+T to open terminal for running commands):

sudo apt-get install gedit

sudo gedit /usr/share/contractor/scratch-openasroot.contract

2. Copy and paste below lines into the file and save it.

[Contractor Entry]
Name=Open file as root
Icon=scratch-text-editor
Description=open file as root with scratch
MimeType=text
Exec=gksudo scratch-text-editor %U
Gettext-Domain=scratch-text-editor

This will add an option “Open file as root” to Pantheon context menu, which open text files as root user with Scratch Text Editor (the default editor for eOS).

Open folders as root in Panthen Context Menu:

1. Use your favorite editor to create and edit the config file:

sudo gedit /usr/share/contractor/folder-openasroot.contract

2. Copy and paste below lines into the file and save it.

[Contractor Entry]
Name=Open folder as root
Icon=pantheon-files
Description=Open current folder as root privilege
MimeType=inode;
Exec=gksudo pantheon-files %U
Gettext-Domain=pantheon-files

This adds the option ‘Open folder as root’ to context menu, which open folders as root privilege.

Remember, you need a restart to get things done. Enjoy!

Twitter

I'm a freelance blogger who started using Ubuntu in 2007 and wishes to share my experiences and some useful tips with Ubuntu beginners and lovers. Please comment to let me know if the tutorial is outdated! And, notify me if you find any typo/grammar/language mistakes. English is not my native language. Contact me via ubuntuhandbook1@gmail.com Buy me a coffee: https://ko-fi.com/ubuntuhandbook1 |

3 responses to Add ‘Open as Administrator’ to Pantheon in Elementary OS Luna

  1. thanks for the write up….’preciate

  2. You might want to add this to your list of items for the right click menu.

    How to add “delete permanetly” option to File’s context menu.
    command:sudo gedit /usr/share/contractor/Delete.contract
    copy and paste into empty file;
    [Contractor Entry]
    Name=Delete permanetly
    Icon=pantheon-files
    Description=Delete files, skip trash
    MimeType=inode;application;audio;chemical;image;message;model;multipart;text;video;x-conference;x-epoc;x-world
    Exec=rm -r
    Gettext-Domain=pantheon-files

    I could not find this anywhere, so created it. If there is a better way, let me know.
    Thanks and have a nice day.