Can you grant an app root while running?

Basically I was editing a file and I couldn't save due to not having launched gedit with root privileges. Is there a way to give it root on the fly?

I do not think it is possible.
It would undermine the built in security feature of Linux OS.


A workaround would be, if this happens and you do not want to lose your work, open the file with root privileges and then copy paste your changes over. In most cases, "Select all" can be used to keep it simple.
Then save the newly opened Root instance.


Correct, use the SUDO command followed by a space, in front of the name of the APP you wish to run. Terminal will often recommend against this as it will state its dogma that the application should not need root privileges to run. Yeah well, who asked terminal for its opinion anyways?

Additionally, you can to this file manager wide by running the command...

sudo nautilus

This will open the file manager as root. Then from there, you can access any files, folders, launch them with root, or even change access permissions too.


Better yet, you can add this function to run as administrator to Nautilus (and other file managers which are missing this function).


I prefer to elevate terminal to Root

sudo -i

Then launch the file manager from Root Terminal.


The Problem With Sudo Nautilus:

  • It runs Root Nautilus from Home Directory. This can potentially cause root file ownership to be transferred from root to home, even resulting in being unable to boot your system.
  • It is less secure as it is less precise. It grants root privileges to all GUI during that instance.

Alternatively, you can use pkexec. I wrote a guide on here about how to "mimic' the old "gksudo" days by expanding pkexec and allowing it to perform even if you type "gksudo nautilus" in terminal.

1 Like

... do not want to lose your work, open the file with root privileges and then copy paste your changes over.

That's exactly what I did, sudo gedit -> reopened the file, copied all content in clipboard from the read only one and pasted in the sudo'ed one.

For the long run I will use FrenchPress's solution, that admin addon for nautilus does the job. I'm used to right click & run as administrator from Windows.


This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.