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

root-privilege.jpgUbuntu 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

Damien Oh is the owner and chief editor of Make Tech Easier

 

Enjoyed the article? Subscribe to Make Tech Easier today to get your daily updates of technology tutorials, tips and tricks.

Enter your email:

1 pingback/trackback (Click to open)

10 Responses

  • Tasos says:

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

    Reply

  • anonymous coward says:

    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.

    Reply

  • bahh says:

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

    Reply

    robsku Reply:

    @bahh
    Option 2: Install ‘nautilus-gksu’

    Sooo… what is it exactly that seems so hard to you? Can’t get much easyer, huh?

    This kinda smells like troll really, unless you accidentally missed option two (numbers 1 and 3 are not exactly rocket science either but nobody can claim that option two is not easy.

    Reply

  • Placebo says:

    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.

    Reply

  • heyjohnreese says:

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

    Reply

  • stari veselin says:

    Thanks, this helped!

    Reply

  • Sikku says:

    How to use this in Fedora with gnome destkop???

    Reply

    Damien Reply:

    I am not really proficient in Fedora, so I can’t be of any help in this.

    Reply

  • Jamal says:

    Thanks for this bro, really helped me out!

    Reply

Leave a Comment




 

Sign in with Twitter

Comment

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