Published: 2012-Jun-13 17:35

Run as root ubuntu 12.04

This might work on other versions of ubuntu and other Linux distributions.

  1. Create a place to keep the launcher. I have a folder in my UbuntuOne called launchers.

  2. create a file, lets call it "my_launcher" for this example. (I use vim, but gedit will work just as well.)

  3. write:

    \[Desktop Entry\]  
    Name\[en\_GB\]=etherape as root  
    Exec=gksudo -k -u root etherape  
    Name=etherape as root  
  4. save it and change the permissions to 775 (rwxrwxr-x) which you can do on the command line, (if you are in the same directory as the new file), with:

     chmod 775 my\_launcher

    or by right-clicking on the icon, at the bottom should be Properties and hidden in there will be permissions - just set them all except for Others: write (though you should try to learn about that and the scary implications before blindly following some random blog - Linux lets you do almost anything... including shooting yourself in the foot.)

  5. drag it to the launcher for easy access.

The magic line is:

Exec=gksudo -k -u root etherape

This runs, in this case, etherape as root, (that pesky Administrator in the Linux world.)

( If you have terminal already open then:

gnome-desktop-item-edit --create-new ~/Desktop

is also an option.)

Much of the reset of the entry can be changed or removed. Want to edit something as root?

#!/usr/bin/env xdg-open  
\[Desktop Entry\]  
Exec=gkedit -k -u root gedit  

and the amazing thing - this is just text, but you are now a programmer, (yeah maybe get some scripting language and compiled languages under your belt before adding programmer to your C.V.).

p.s. I have no idea why gedit needs xdg-open and etherape does not, but I'm sure someone in the comments knows...