Learn to add an “Open as Administrator” option in the right click context menu in Nautilus file manager in Ubuntu and other Linux distributions.
If you want to open or edit a file as root, you can always do that in the terminal. I know a few people don’t feel too comfortable with the command line.
The desktop Linux often provides ways to avoid the command line for terminal-fearing people.
If you are in a situation where you have to access a folder as root or edit a file with root privilege, you can do that graphically in Nautilus file manager.
A neat Nautilus hack allows you to open a files and folders as administrator i.e. root. Let me show you how.
Add ‘open as administrator’ option in right click context menu in Nautilus file manager
A word of warning! Please don’t go around opening and editing random files as root as you might mess up with wrong files and end up with a broken system. Use it only in the cases where it is required.
I am showing the installation steps for Ubuntu. You can change it as per your distribution’s package manager.
You’ll have to use terminal (even if you don’t like it) for installing the Nautilus plugin. Please make sure that you have the universe repository enabled:
sudo apt install nautilus-admin
Close and open Nautilus file manager again to see the changes in effect.
You can also edit files as root the same way. Just select the file, right click on it and choose the “Edit as Administrator” option.
In both cases, you’ll be prompted to enter your account’s password:
That’s pretty much it. You can enjoy the comfort of GUI.
In case you don’t want to run Nautilus as root anymore, you can remove this plugin. It’s always good to remove additional things you installed but you don’t use anymore.
In the terminal (yes, again), use the following command to remove the Nautilus plugin.
sudo apt remove nautilus-admin
By the way, if you are using Ubuntu MATE, you can use caja-admin, instead of nautilus-admin. Other file managers may or may not provide such a feature.
I hope you find this quick tip helpful. Questions and suggestions are always welcome.