Opening file as root is possible with sudo. But, how to right click a file and make it run as root ?
I am using nautilus.
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.
Sign up to join this communityYou need the admin extension
$ apt-cache search nautilus | grep admin
nautilus-admin - Extension for Nautilus to do administrative operations
Install it with sudo apt-get install nautilus-admin
run as root
in context menu.
I tested the solution from here, and it works fine (running 14.04/nautilus).
To not post a link-only answer:
install gksu
sudo apt-get install gksu
Navigate to ~/.local/share/nautilus/scripts
Create and open an empty file, name it open-as-administrator
, paste the script below:
#!/bin/bash
#
# this code will determine exactly the path and the type of object,
# then it will decide use gedit or nautilus to open it by ROOT permission
#
# Determine the path
if [ -e -n $1 ]; then
obj="$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS"
else
base="`echo $NAUTILUS_SCRIPT_CURRENT_URI | cut -d'/' -f3- | sed 's/%20/ /g'`"
obj="$base/${1##*/}"
fi
# Determine the type and run as ROOT
if [ -f "$obj" ]; then
gksu gedit "$obj"
elif [ -d "$obj" ]; then
gksu nautilus "$obj"
fi
exit 0
Make the script executable
Either log out and back in, or run:
nautilus -q
AGAIN: the script is not mine! found it on http://ubuntuhandbook.org
sudo apt-get install nautilus-admin
method instead of making your own system scripts. Then you will get updates when/id needed.