Want to enable ‘Open as Administrator’ (aka ‘Open as Root’) in your file browser context menu? Here’s the beginner’s guide shows you how with a quick fix for Ubuntu 21.04.
The tutorial will work on:
This tutorial will work on all current Ubuntu releases, including Ubuntu 18.04, Ubuntu 20.04, Ubuntu 20.10, and Ubuntu 21.04. And it’s for the default Nautilus file browser.
1.) Install nautilus-admin extension:
Ubuntu comes with the
nautilus-admin package in the main repositories. With it, you’ll get “Edit as Administrator” option for documents, and “Open as Administrator” option for folders.
To install it, press Ctrl+Alt+T on keyboard to open terminal and run command:
sudo apt install nautilus-admin
Tip: For Ubuntu MATE or Linux Mint MATE desktop, there's also a similar package called
caja-adminfor the Caja file browser.
2.) Restart nautilus to apply change:
After installed the extension, you need to apply change by restarting nautilus via command:
Or you can just log out and back in. And it should work afterwards.
3.) Fix / Workaround for Ubuntu 21.04:
In Ubuntu 21.04 Hirsute Hippo, there are two issues in my case. If you get into the same problem, here’s a workaround.
a.) Extension does not work due to module import error:
nautilus -q command will output an error message:
Traceback (most recent call last):
File “/usr/share/nautilus-python/extensions/nautilus-admin.py”, line 25, in
from gettext import gettext, locale, bindtextdomain, textdomain
ImportError: cannot import name ‘locale’ from ‘gettext’ (/usr/lib/python3.9/gettext.py)
This is due to a small change in the Python 3.9 library. To fix it, do the steps below one by one:
- Firstly press Ctrl+Alt+T on keyboard to open terminal. When it open, run command to edit the extension script:
sudo gedit /usr/share/nautilus-python/extensions/nautilus-admin.py
- When file opens, find out this line:
import os, subprocessand change it into:
import os, subprocess, locale
- Next find out the line:
from gettext import gettext, locale, bindtextdomain, textdomainand remove
Finally save the file and restart Nautilus via
nautilus -q command.
b.) Workaround for nautilus admin & gedit admin error:
Due to update of the gvfs package, you’ll get an error when using ‘Open as Admin’ action:
GDBus.Error:org.freedesktop.PolicyKit1.Error.Failed: Unix process subject does not have uid set
It’s a bug caused by the commit to fix a network permission issue for flatpak apps. As a workaround, you can revert the commit. However, there could be some other issue that’s preventing this change from working as expected.
- Rebuild the gvfs source yourself with a patch to revert the commint.
- Or downgrade gvfs by installing the package from Ubuntu 20.10.
And here’s how to install the gvfs packages from Ubuntu 20.10:
- Firstly, download the .deb packages (for 64-bit system) one by one by clicking the following links:
- Secondly, press Ctrl+Alt+T to open terminal and run command to install all downloaded deb packages:
sudo apt install ./Downloads/gvfs*.deb
Finally restart your machine to apply changes.
That’s it. Enjoy!