How to add ‘Open File/Folder as Root’ in Elementary OS Freya

Elementary OS Freya. Simple. Elegant. But there is still some things I miss, like the option to open a folder or a file with root permissions from the file explorer. With these easy steps this issue can be easily solved:

1.- Install gksu in order to be able to prompt for superuser permissions from the window manager.

sudo apt-get install gksu
									

2.- Create the “open folder as root” contractor.

sudo touch /usr/share/contractor/folder-openasroot.contract && gksudo scratch-text-editor /usr/share/contractor/folder-openasroot.contract
									

3.- Add this to the contractor:

[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
									

4.- Create the “open file as root” contractor.

sudo touch /usr/share/contractor/file-openasroot.contract && gksudo scratch-text-editor /usr/share/contractor/file-openasroot.contract
									

5.- Add this code to the contractor:

[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
									

And… Done!