📖Open as Admin

There are cases when you may need to open and edit a file as administrator (as a rule, when you need to edit configuration files in your root directory.

Be extremely careful when changing /root files. Unthoughtful actions can break your system.

Always be absolutely sure in what you are doing!

You can always use your Terminal and command line to open and edit files as root. Still, command line is not comfortable for everyone to use.

In elementary OS, you can open a new window of the file manager as administrator first and then open and edit all files. But a more convenient way to open a single file from the Pantheon file manager is to create a context menu item Edit as Admin (create a new contract file).

  1. Open your Terminal and run:

cd /usr/share/contractor
  1. Create a new contract file by running the following:

sudo nano io.elementary.code.open-as-root.contract
  1. Enter your admin password.

  2. Insert the following info to the created file:

[Contractor Entry]
Name=Edit as Administrator
Icon=io.elementary11oko.code
Description=Edit file via root user privilege
MimeType=text/plain;
Exec=pkexec io.elementary.code %U
Gettext-Domain=code
  1. Press Ctrl+O to save, and Ctrl+X to exit.

Now when you secondary click a root file in the file manager, you can see the Edit as Administrator context menu item.

Click to open, submit your admin password, and edit the file.

All thanks to Tiwo Satriatama for the manual. Watch the video guide here.

Last updated