Enable Open As Administrator on Ubuntu 16.04 / 17.10 / 18.04

For students and new users, sometimes it’s nice to have the ability to edit file and open folders as root or administrator… You probably don’t want to always use the sudo command via the terminal to edit configuration files.

If you can easily browse to a file via Nautilus or file explorer and edit it using the default editor can be useful especially for students and new users…

For example, if you want to edit Ubuntu hostname file, simple browse to /etc/hostname, then right-click the file and select Edit as Administrator… doing this will allow you to make changes and save those changes with administrative rights…

This brief tutorial is going to show students and new users how to enable Edit / Open As Administrator or root on Ubuntu 16.04 / 17.10 and 18.04.When you’re ready to enable this change, follow the steps below:

Step 1: Install Nautilus Admin Tool

To enable this feature, you must first install Nautilus administrator tool… doing this will allow you to edit file and open folders as administrator..

To install the tool, open Ubuntu terminal or press Ctrl — Alt — T on your keyboard to open the terminal app… then run the commands below

sudo apt install nautilus-admin

After that, open Nautilus file browser and test…

Step 2: Using Nautilus Admin

Now that the tool is installed, all you have to do is open Nautilus file browser, right-click a file  or folder and select Open As Administrator as shown in the image below…

First run the commands below to reload Nautilus….

sudo nautilus -q

ubuntu open as admin

When you want to edit files, you’ll see Edit as Administrator… on Folders, you’ll get Open as Administrator. Doing that will prompt you to type your password… this only works if your account is already member on the sudo approved list.. if the user opening a file isn’t authorized to use the sudo command, it won’t work…

This is a very useful tool especially if you’re new to Linux and Ubuntu…

Summary:

This post shows students and new users how to easily enable Open as Administrator on Ubuntu desktops… For students this can be a great way to edit basic file configurations without using the command line terminal.

Enjoy!

You may also like the post below:

Change Apache2 HTTP Default Port on Ubuntu 16.04 / 17.10 / 18.04

7 Replies to “Enable Open As Administrator on Ubuntu 16.04 / 17.10 / 18.04

  1. These instructions are the basic ones and they should work. But, for some reason, they do not work for me in Ubuntu 17.10, perhaps because my system is not properly configured. The problem is that the root user is not allowed access to the X server. So, you click on “Edit as Administrator”, enter the password and then nothing happen. If you try $ pkexec gedit directly on the command line on a terminal, you get the same login window and, after you enter the password, you see the error message “Invalid MIT-MAGIC-COOKIE-1 keyUnable to init server: Could not connect: Connection refused.” This is because, in my case and in the case of many others, the root user does not have access to the X server. The solution is to add the root user with the command $ xhost + SI:localuser:root. To make it permanent you add the command at the bottom of the ~/.bashrc file. The details are explained here http://ubuntuhandbook.org/index.php/2017/10/ubuntu-17-10-tip-graphical-apps-doesnt-launch-via-root-sudo-gksu/ .

  2. On Ubuntu 18.04, When you run “sudo nautilus -q” you get…
    “sys:1: PyGIWarning: Nautilus was imported without specifying a version first. Use gi.require_version(‘Nautilus’, ‘3.0’) before import to ensure that the right version gets loaded.”

    1. Yep, I got the same response. I’m running Ubuntu 18.04 also. Learning Linux so this is over my head at this time.

      1. Try this: In Ubuntu 18.04 LTS: Install Synaptic Package Manager using Ubuntu Software, then from within Synaptic search for “nautilus-admin”, select it for installation, and apply changes. Synaptic will install the necessary dependencies automatically.

  3. Heya excellent blog! Does running a blog such as this take a massive amount work? I have virtually no understanding of computer programming however I was hoping to start my own blog soon. Anyway, should you have any recommendations or tips for new blog owners please share. I know this is off subject however I just wanted to ask. Appreciate it!

  4. I got this same error in Ubuntu 18.04:
    “sys:1: PyGIWarning: Nautilus was imported without specifying a version first. Use gi.require_version(‘Nautilus’, ‘3.0’) before import to ensure that the right version gets loaded.”

    Anyway, “Edit as Administrator” worked when opening Nautilus.

    My question now is:
    My default text editor is Notepadqq, but when opening a file using “Edit as Admin” it opens through Gedit.
    There is a way to change it?

    Thanks

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: