Run As Root From File Browser

Ubuntu – suppose you need to make changes to a file which is not user-editable. Or you have an installation script that must be run as root. The most commonly offered solution is to fire up a terminal, change into the directory containing the file and type

sudo gedit filename

or

sudo script.sh

However, there is a solution that does not involve the terminal at all. Use File Browser to get to the file, right-click on it, and select Open with Other Application…

Expand Use a custom command at the bottom of the Open with window to reveal a text entry field, and type

gksudo gedit

if you want to open a text file, or simply

gksudo

to launch a script.

Screenshot of Open with… dialog

Click Open. A standard password-entry window will pop up, and after you enter your password, your file will open with root access.

Leave a Reply