Ubuntu – Add Open Folder as Root to PCMan File Manager’s context menu

lubuntu

In the latest version of the PCManFM the option under Tools-Open Current Folder as Root has been removed. Is there a way to re-add the option? I know I can open PCManFM as Root via the Terminal but it was handy to open the specific Folder under the Tools option. Also is there a way to add the option as a Context Menu entry?

I didn't understand the Desktop file specification extension (DES-EMA).

I found this:

[Desktop Entry]
Name = Open as Root
Tooltip = Open the folder as root
Icon = terminal
Profiles = on_folder;

[X-Action-Profile on_folder]
Name = Open as Root
MimeTypes = inode/directory;
SelectionCount = 1
Exec = gksudo pcmanfm %s

I then name the file pcman_root.desktop and place the file into: ~/.local/share/file-manager/actions. Unfurtunately, I do not have the folder file-manager/actions under the ~/.local/share directory. Am I supposed to create that specific folder?

Best Answer

You are on the right track.

Create ~/.local/share/file-manager/actions.

In that folder, create root.desktop (not pcman_root.desktop or anything else).

Add this content:

[Desktop Entry]
Type=Action
Tooltip=Open Folder As Root
Name=Open Folder As Root
Profiles=profile-zero;
Icon=gtk-dialog-authentication

[X-Action-Profile profile-zero]
MimeTypes=inode/directory;
Exec=/usr/bin/gksu /usr/bin/pcmanfm %u
Name=Default profile

Save the file.

(Or download the script from here.)

Restart PCManFM (System Tools, Task Manager, terminate or kill pcmanfm, then start it again). Now, when you right-click on a folder, you should see the "Open as root" option in the context menu.

enter image description here

As others have stated, this feature can be dangerous which is why it is not there by default.

And this is what a developer associated with the PCManFM project has to say in response to a "request" for the feature to be restored:

Running pcmanfm as root means all the applications will be ran under root which is not safe you know (well, if you want to risk your system and walk on the blade then I can see the reason) and I never saw any reason to run editor/browser/wine/etc. under root (and you want exactly this, don't you?)

But anyway if you so much want to do this risky things then why you never read http://wiki.lxde.org/en/PCManFM#Run_as_root page? Yes, it was changed lately but it is still available, at your own risk.

Related Question