Adding run as root for nautilus in unity
Solution 1
To add the option to run as root to the nautilus (Files
) launcher:
-
Copy the
.desktop
file, representing nautilus in the launcher, from the global directory/usr/share/applications
to~/.local/share/applications
which is on 14.04 and 14.10 :
nautilus.desktop
:cp /usr/share/applications/nautilus.desktop ~/.local/share/applications
and on 15.04 and 15.10 :
org.gnome.Nautilus.desktop
cp /usr/share/applications/org.gnome.Nautilus.desktop ~/.local/share/applications
-
Open the file with (e.g.)
gedit
, look for the line:Actions=Window;
Change it into:
Actions=Window;Open as root;
Add to the very end of the file:
[Desktop Action Open as root] Name=Open as root Exec=gksu nautilus
Save and close the file.
-
Install
gksu
, to be able to enter your password via GUI:sudo apt-get install gksu
-
Finally, log out/in to make Unity "aware" of the local, edited
.desktop
file.
That's about it.
Note
In some cases, you might have some doubts on what is the correct .desktop
file to edit. This question on nautilus
is a good example, since nautilus represents itself in a different .desktop
file in the launcher on different Ubuntu versions, while nautilus has multiple .desktop
files in /usr/share/applications
.
To be sure to edit the correct one, simply run:
gsettings get com.canonical.Unity.Launcher favorites
which will output a list of current .desktop
files, used in the launcher.
Solution 2
Use pkexec
instead of gksu
The use of gksu
and gksudo
is not recommended any more. The recommended method is to use Polkit. The easiest way to add Polkit files for Nautilus
is to install nautilus-admin
To install nautilus-admin
in Ubuntu, open a terminal by pressing Ctrl+Alt+T and use the following command:
sudo apt-get install nautilus-admin
The rest involves editing the `nautilus.desktop file and adding the correct command:
-
Copy the
nautilus.desktop
file, representing nautilus in the launcher, from the global directory/usr/share/applications
to~/.local/share/applications
cp /usr/share/applications/nautilus.desktop ~/.local/share/applications
-
Open the file with (e.g.)
gedit
, look for the line:Actions=Window;
Change it into:
Actions=Window;Open as Administrator;
Add to the very end of the file:
[Desktop Action Open as Administrator]
Name=Open as Administrator
Exec=pkexec nautilus
Save and close the file.
The added bonus of installing nautilus-admin
is that within Nautilus
you will also get Open as Administrator / Edit as Administrator items for folders / text files in the right click context menu. See How do I start Nautilus as root? for more details.
Hope this helps
Solution 3
For me under Ubuntu 16.10 the relevant .desktop file for nautilus was
/usr/share/applications/nautilus.desktop
Even though gsettings get com.canonical.Unity.Launcher favorites
returned application://org.gnome.Nautilus.desktop
Also note, that in order for the above gsettings
command to print nautilus
at all, nautilus
needs to be locked/pinned to the launcher.
Related videos on Youtube
Community
Updated on September 18, 2022Comments
-
Community over 1 year
I am seeking for a way to make run as root option shown in "Files" context menu of Unity so, I get rid of using terminal every time I want to access nautilus as a root.
I found the original concept here, except for I didn`t find the file need to edit: How do I start Nautilus as root?
-
Admin over 8 yearsWhat is your Ubuntu version?
-
Admin over 8 years@JacobVlijm it is 15.10
-
Admin over 8 yearsOk. thanks will post an answer in a few minutes.
-
Admin over 8 years@Maythux I don't think so. The (this) question is on how to add it to the Unity Launcher as a right- click option (shown in "Files" context menu of Unity). Also, 15.10 uses a different ` .desktop` file in the launcher, so even if you take the answers as a criterion (which you shouldn't) , it would be outdated.
-
Admin over 8 years@Maythux again, the question is the criterion, not possible answer(s), and the answer is even outdated for 15.10.
-
Admin over 8 years@JacobVlijm ok its my fault.sorry
-
Admin about 7 yearsAlso see How to start Nautilus as root
-
-
Fabby over 8 yearsOr just use
nemo
... >:-) -
Elder Geek about 7 yearsComment by derwiwie Note that in order for the above gsettings command to print nautilus at all, nautilus needs to be locked/pinned to the launcher.
-
WinEunuuchs2Unix about 6 years@Fabby "Be Nice :)" about gksu and nautilus: meta.askubuntu.com/questions/17687/…
-
Fabby about 6 years@WinEunuuchs2Unix upvoted your answer there... Never in chat any more?
-
WinEunuuchs2Unix about 6 years@Fabby No. I'm kind of an anti-war guy and the HRC extremists (or some people like that) leveled a 30 day chat ban against me last year. So I decided it was a bad place to hang out. Thanks for upvoting my anti-anti-gksu gedit answer though :)