File manager

How To Edit Files As Root In Ubuntu Using GUI File Manager

Learn how to edit text and other files on Ubuntu as the root user using the Nautilus GUI file manager without using the command terminal. The tutorial is valid for all Ubuntu versions such as 22.04, 20.04 and 18.04…

What is Nautilus?

Nautilus is the default file manager for the GNOME desktop environment, including Ubuntu. Nautilus Filemanager features include creating and managing files, previewing selected file types, and accessing remote shares. In addition, it has an interface for extensions, which makes it possible to expand the range of functions.

In addition to clicking the file manager icon, users can open it by typing nautilus in the command terminal. Also, by default, Nautilus does not show hidden files. With the keyboard shortcut Ctrl + H hidden files can be shown and hidden again.

However, one feature that won’t be there is to edit system files as root or sudo user directly from the Nautilus file manager GUI on Ubuntu. However, there is a way to do it. It will not save user time but also allow users to edit system files without using command terminal.

Steps to edit files as root or sudo user in Ubuntu Nautilus File Manager

The tutorial is not limited to Ubuntu only. Any other Ubuntu or Debian based Linux using Gnome/Nautilus as the default UI can follow the commands given in this tutorial.

1. Open the command terminal

I can understand you might be wondering here we are talking about GUI File Manager so what is the need to use command terminal. This is because we need to install a feature required by the Nautilus. Also, updating the system using the command line is an easy way. To open Terminal, users can either use the keyboard shortcut which is Ctrl+Alt+T or search for it using the app launcher.

2. Update Ubuntu Linux

It is recommended to run the system update command before installing any software. Yes, we need to install an extension for our Nautilus file manager to get functionality that allows us to edit files as root. Therefore, let’s start by updating the system.

sudo apt update && sudo apt upgrade

2. Install the Nautilus Admin extension

As with other file managers, right-clicking on a file or folder opens a context menu. The same goes for Nautilus with operations like copy, move, move to trash, compress, etc. offered but not that of editing files as a Super Admin user. Therefore, to incorporate this, run the given command:

sudo apt install nautilus-admin

3. Restart your Linux system

Once you have installed the Admin feature for your Nautilus file manager, reboot your system to integrate it properly.

sudo reboot

4. Edit files as root through the Nautilus GUI file manager

Open your file manager and navigate to a file that can only be edited with root user rights. After this right click on this file and in the context menu this time you will see an additional option “Edit as administratorr”.

When you click on the option, the system will ask for your sudo user password, provide it.

Here we are editing the system Sources.list file which is only accessible by the user with root rights.

5. Remove Edit Files as Root Feature on Ubuntu

Well, if you don’t want this admin feature enabled on your Ubuntu, we can remove the Admin extension from our Nautilus file manager using the command.

sudo apt remove --purge nautilus-admin

Other Items:

How to Reset Ubuntu 22.04 LTS Root Password
Set root user password in Ubuntu 20.04 LTS focal fossa
How to Open Ubuntu File Manager as Root User
How to Install Nautilus GUI File Manager on WSL -Windows