Score:1

Unable to launch any script with sudo command in, when launched from Nautilus script menu

cn flag

Is there a new way to launch nautilus from a basic script?

#!/bin/bash
echo "Open File Manager as Root"
sudo nautilus

Opening from Nautilus scripts context menu does not launch Nautilus if sudo is present (opens Nautilus from the scripts context menu if sudo is removed), however, his opens Nautilus with password prompt if run as a program.

Tried:

nautilus admin:///home/

Tried this, but does not work for me, just generates an error when Nautilus launches. Policykit1 error, does not have a uid set

Suggestions here but none of this works, or the answer is unclear and I am missing something.

Note: When trying to launch any script with sudo in from the Nautilus script menu, none of these scripts will launch.

Tried:

sudo apt-get install nautilus-admin

This did not work, Policykit1 error

Found this here that got Open as Administrator to work here

sudo add-apt-repository ppa:ubuntuhandbook1/gvfs
sudo apt install gvfs-fuse
sudo apt install gvfs

Reboot

How to Restore GVfs to stock version:

sudo apt install ppa-purge && sudo ppa-purge ppa:ubuntuhandbook1/gvfs

I found that this worked for me:

#!/bin/bash 
gnome-terminal -- sh -c 'echo "sudo nautilus" | bash'

Now when I use the Nautilus script menu I can launch a root Nautilus session.

This also worked as suggested below:

#!/bin/bash
pkexec env DISPLAY="$DISPLAY" XAUTHORITY="$XAUTHORITY" nautilus
N0rbert avatar
zw flag
Does this answer your question? [How do I start Nautilus as root?](https://askubuntu.com/questions/156998/how-do-i-start-nautilus-as-root) . Use `nautilus admin://`.
pst007x avatar
cn flag
Tried this, but does not work for me, just generates an error when Nautilus launches. Policykit1 error, does not have a uid set
vanadium avatar
cn flag
The nautilus-admin extension remains the cleanest way for opening a nautilus window as rood.
Score:1
cn flag

I believe you are looking for pkexec. This works on my system to launch nautilus as root with a graphical password prompt:

#!/bin/bash

pkexec env DISPLAY="$DISPLAY" XAUTHORITY="$XAUTHORITY" nautilus

You need to set the DISPLAY and XAUTHORITY variables to be able to launch GUI programs with pkexec, but it should work like gksu used to.

pst007x avatar
cn flag
Thanks, that worked
Score:0
sa flag

Try

sudo -E nautilus

I don't have nautilus, but my own fillemanger works that way.

pst007x avatar
cn flag
Thanks, the same issue. When trying to launch any script with sudo in from the Nautilus script menu, nothing will launch. I installed Dolphin, and that works like a dream.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.