Post

Ubuntu: Easy (And Quick) Ways To Open Any Files As Root

root-privilege.jpg
Photo by jennie-o

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

For more technology news, tips and tricks, subscribe to Make Tech Easier today.

Popularity: 6% [?]

 

5 Comments Received

 
Tasos
February 20th, 2008 @8:01 am  

If you used KDE, you would know that you dont have to all this because Konqueror has this installed by default.

anonymous coward
February 20th, 2008 @8:54 am  

To do the same thing in kde:
Left click desktop> create new…>link to application>
Put kdesu konqueror for a root privileged file browsing window. kdesu ….. for whatever root app you want.

bahh
March 28th, 2008 @1:08 am  

Is there nothing that is easy in Linux. This OS SUCKS. I cant believe I actually fell for it and wasted 3 dam days.

Placebo
July 2nd, 2008 @8:41 am  

Thanks for the help man! You really saved me from having to refer to the terminal every time I need to edit and move files.

heyjohnreese
July 14th, 2008 @7:35 pm  

Great tips, Ive been looking for an easier way to edit root files. Thanks!

Leave A Reply

Please Note: Comments maybe under moderation after you submit your comments so there is no need to resubmit your comment again