Ubuntu does not allow its users to login as root directly. For users who want to run programs (or edit files) with root privileges, they have to use “sudo” to allow access to root. While this is a very useful feature to protect your system, it can be a troublesome and repetitive task.
Instead of hitting the terminal and enter the ‘sudo‘ command everytime you need to open a file with root privilege, you can use any of the following methods to easily access your files with a mouse click.
1) Create a gksudo Launcher
- Right-click unused space in either the top or bottom panel.
- Choose “Add To Panel…”
- Choose Custom Application Launcher
- In the window that pops up, enter the following:
Name: GKSudo launcher
Command: gksudo “gnome-open %u”
Comment: Open files with root privilege
- Click the No Icon button to select an icon for your launcher.
- Click OK
Your Gksudo launcher should now appear on the panel.
Now, to open a file with root privilege, just drag and drop the file to this launcher.
2) Install ‘nautilus-gksu’
Install ‘nautilus-gksu‘ via the Synaptic Package Manager. Now when you right click on any files or folder, you can see the option “Open as administrator“.
3) Use nautilus-script
If for some reason, you can’t install the ‘nautilus-gksu‘, you can achieve the same function via creating a nautilus script manually.
In the terminal,
gedit $HOME/.gnome2/nautilus-scripts/Open\ as\ Administrator
Insert the following lines into the new file:
for uri in $NAUTILUS_SCRIPT_SELECTED_URIS; do gksudo “gnome-open $uri” & done
Save the file.
Make the file executable:
chmod +x $HOME/.gnome2/nautilus-scripts/Open\ as\ Administrator
You can now open files as root by right clicking on the file and selecting Scripts->Open as Administrator