How To Add ‘Open folder as Root’ In Elementary OS Right Click Menu

Question: How can I create right menu context that open folders as root in Elementary OS.

openasroot

Answer: To create ‘Open folder as root’ context menu command we need to create a .contract at the location below:

/usr/share/contractor

To create this file,

Open your favourite text editor and copy and paste the code below into it:

[Contractor Entry]
Name=Open folder as root
Icon=gksu-root-terminal
Description=Open folder as root
MimeType=inode;application/x-sh;application/x-executable;
Exec=gksudo pantheon-files -d %U
Gettext-Domain=pantheon-files

Save it as openasroot.contract and move to /usr/share/contractor:

sudo mv openasroot.contract /usr/share/contractor/

For vi users,

just run:

sudo vi /usr/share/contractor/openasroot.contract

then paste the code above.

And, you’re done!