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 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!