How to easily add a context menu item that enables a Linux user to open files as root or administrator via right mouse click when browsing a file system. This feature allows the user to navigate their file system and open or edit any file or directory as the root user or admin of the system. It is a great solution for those that are not completely comfortable using terminal commands.
Note: The following process assumes you're using a Debian based system with nautilus. Ubuntu and other Debian based remixes should also work. An Ubuntu Linux Live USB was used in the example here. If you follow along from a fully extracted Linux installation, you will need to make sure you add user to sudoers before proceeding.
You'll need to make sure you have the universe repository enabled because "nautilus-admin" is not available from standard repositories.
Add a menu to Right Click Open Files as Root
To add a contextual menu item that enables you to Open files as Root or Administrator with a simple right mouse click:
- Open the Terminal Ctrl + Alt + T
- Type sudo su and press enter.
- Provide your password and press enter
- Then type apt install -y nautilus-admin and press enter
- Now type nautilus -q and press enter
- Finally type exit and press enter, and close the terminal window
Right Click Open Files as Administrator
To open a file as root, simply right click the folder and select Open as Administrator
Pro Tip: If the file manager was already open while you installed nautilus-admin, you'll need to close and reopen it to see the changes. If that doesn't work, simply logoff and then log back in to see the changes!
You now also have the option to edit files as Administrator using a right click.