How to run
Nautilus as administrator with
pkexec instead of
GVfs method tested in Ubuntu 18.04
Use the GVfs admin backend, just add
admin:// to the beginning of the full path to your preferred directory.
Open Nautilus the usual way and press Ctrl+L to enable typing in the address-bar, and then enter for example
admin:///usr/ to open the
Enter your admin password when prompted and you will see something like this:
At this point clicking on the folders with locks will open with admin privileges.
You may bookmark a folder that is opened with
admin:/// prefix. When you click on such a bookmark later you may be prompted for the admin password again.
Alternatively, from the Terminal open nautilus with the argument
to open the /usr/ directory as root in Nautilus.
Editing text files with admin privileges
From Nautilus opened in this way, if you click on a text file that needs admin privileges, you will be prompted for password again, before it opens in your default editor such as Gedit.
If you are using Ubuntu 17.10
The following method does not work with Wayland by default. There are some workarounds. The easiest one is not to use Wayland. How do you switch from Wayland back to Xorg in Ubuntu 17.10? Other alternatives are described in Why don't gksu/gksudo or launching a graphical application with sudo work with Wayland?
Ubuntu will switch back to Xorg by default in 18.04 LTS and the workarounds will not be needed then.
gksu hasn't been updated since 2009 and is not recommended any more. In fact, Ubuntu no longer ships with gksu by default (though it may be installed for many of you, because some apps still depend on it) and it may even be completely removed at some point.
Nautilus admin adds PolicyKit files for both Nautilus and Gedit and it allows opening a file or folder from Nautilus as root, via PolicyKit:
Nautilus Admin in Ubuntu, open a terminal by pressing Ctrl+Alt+T and use the following command:
sudo apt-get install nautilus-admin
And to restart Nautilus use either of the following commands:
nautilus -q or
After this when you right click on a folder you will see:
If you right click on a text file editable by Gedit you will see:
Then you will be prompted for password:
Related question: "Open in terminal" not working on nautilus as root
nautilus-admin also allows opening nautilus as root from the command line. Use the following command instead of
to open nautilus as root.
Hope this helps