This tutorial requires you to install some software. If your Ubuntu Software Center is not working, we have the fixes here.

How to Run a File as Root in Ubuntu

Using the root user for daily tasks can be dangerous to your system, as Linux distros, by design, do not include any safety checks and precautions when running commands as root. As a result, most Linux distros today use “privilege escalation” programs, such as sudo and doas, to provide temporary root access and prevent common user mistakes while configuring system files. We are using sudo for the purposes of this tutorial.

1. Using Nautilus Admin

One of the quickest ways to open any file as the root user in Ubuntu is to install nautilus-admin, a small utility that acts as a plugin for privilege escalation programs in GNOME. It allows you to easily enable root access on a “per-file” basis.

2. With a .Desktop File

Another quick way to open any file as the root user in Ubuntu is through .desktop files. These are special links that allow you to create custom shortcuts for any program in your system and include the ability to execute either sudo or su to launch any program as root. You can also hide your desktop icons if they are causing a distraction.

3. Using a Keybinding With pkexec

Lastly, it is also possible to bind a root command to a specific keyboard shortcut, which can be useful when you want to access a root session quickly. Follow the steps below to create a root keyboard shortcut. Image credit: Alejandro Escamilla via Unsplash. All alterations and screenshots by Ramces Red. Create two new blocks with the labels [Desktop Action RootProg] and [Desktop Action NonRootProg]. Include both the Name= and Exec= variables under each of your new labels. To install Simple X Hotkey Daemon, run: sudo apt install sxkhd. You can learn more about how it works by running: man sxhkd.