This is a step by step tutorial shows how to add “open as root (or administrator)” option in Pantheon file browser in Elementary OS 0.3 Freya.
Elementary OS 0.3 Freya is lightweight and beautiful Linux distribution based on Ubuntu 14.04 LTS. Its default Pantheon file browser now has ‘Open in terminal’ option in folders’ context menu out-of-the-box.
But if you want to open a file or folder as root permission in Pantheon, you have to do a little tweak on your system.
1. Open Software Center, search for and install gksu, a graphical frontend to su. It’s useful to graphical programs that need to ask a use’s password to run program as another user.
2. Open terminal from the Application menu.
3. Copy and paste below command in terminal and hit run:
sudo touch /usr/share/contractor/folder-openasroot.contract && gksudo scratch-text-editor /usr/share/contractor/folder-openasroot.contract
The code before ‘&&’ will create a empty file ‘folder-openasroot.contract’ under /usr/share/contractor directory, and the code after will open the file with the Scratch text editor.
When the file opens, paste below context and close the file (It’ll be saved automatically).
Name=Open folder as root
Description=Open current folder as root privilege
Exec=gksudo pantheon-files %U
Now re-open your file browser and you’ll see the “Open folder as root” in folders’ context menu.
4. Similar to step 3, to add “Open file as root”, run below command instead:
sudo touch /usr/share/contractor/file-openasroot.contract && gksudo scratch-text-editor /usr/share/contractor/file-openasroot.contract
When the file opens, paste below and close it.
Name=Open file as root
Description=open file as root with scratch
Exec=gksudo scratch-text-editor %U