Edit files and folders as administrator

While working with files and folders as a Linux Administrator, we frequently need to access and edit files and folders that require root permissions. We usually perform this task through the Ubuntu Terminal(the command line utility) using the sudo function. However, when we need to edit files that require root privileges through the Graphical Interface, we need to have a solid workaround for that.

The latest versions of Ubuntu, like Ubuntu 18.o4 LTS, comes with a default file manager by the name of Nautilus. This open source file manager created for our GNOME desktops gives us a way to manage our files and applications. It also lets us open and edit our files and folders as an Ubuntu administrator. Other features that it provides include:

  • Creating folders and documents
  • Displaying files and folders
  • Searching for and managing files
  • Run scripts and applications as an administrator
  • Install and remove fonts etc.

Luckily my version of Ubuntu, Ubuntu 18.04, comes with this utility by default; you can install it by following the steps described in the following section.

Installing Nautilus

The following steps will help you in installing the Nautilus file manager to your Ubuntu system:

Open the Terminal through Ctrl+Alt+T or through the Ubuntu dash.

Run the following command as an administrator:

$ sudo apt install nautilus-admin

Install Nautilus

Enter Y when prompted about the use of additional disk space.

Nautilus will be installed on your system. You can check it by entering Nautilus in your Ubuntu Dash as follows:

Nautilus is now the file manager in Ubuntu

The file manager in your system is now Nautilus.

Opening a Folder as an Administrator

Let us suppose that you need to open a folder that requires root permission. You can access the folder through the UI file manager, right click and then select Open as Administrator from the menu.

Example:

In this example, we want to access the root folder from Other Locations. Since this folder requires root privileges, we will access it as follows:

Open Nautilus

You will be asked to provide authentication information, after which you will be able to access the contents of the folder.

Editing a File as an Administrator

If you want to edit a file, say a system configuration file, that requires root permissions, the Nautilus file manager allows you to edit that file as an administrator. You just need to access that file and then right click and select Edit as Administrator from the menu.

Example:

Lets us suppose I want to edit a secure file ‘evm’ located at /sys/kernel/security. When I open it through the usual method, I will get the following message: Could not open file warning

The workaround is to open the file through Nautilus as follows:

Edit as administrator

After providing the authentication details, you will be able to access and edit the contents of the file.

The Nautilus file manager that you learned to install and use through this tutorial will save you from using the terminal every time you want to access and edit contents of a secure file or folder on your Ubuntu system.

How to Open and Edit Files and Folders in Ubuntu Desktop as an Administrator