Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Mainly I am looking for a way to pin an application to the Unity launch bar, and run it as root.

Currently, even if I start the application with sudo, and pin it after it starts, it will start as current user next time.

Sad, but there is no context menu option "run as ...".

Update: I switched to gnome3 and now I'm happy, I'm missing only the search.

share|improve this question
If you know the risk of running graphical apps as root and still want to continue then follow step 1 here: – edm Apr 4 '12 at 10:31
You did not understand the question, I know how to use sudo and I already tunned it. The question is about how can I create a shortcut to Ubuntu Unity launcher to app that I want to run as root. – sorin Apr 4 '12 at 11:40
For unity launcher, I don't know. But if you have a file residing on your desktop and you want to run it as gksu, then you can install "nautilus execute" extension. – Curious Apprentice Mar 24 '13 at 10:28
up vote 54 down vote accepted

If you want the app to always run as root

1) Pin the application to the launcher as normal.

2) Locate the applications .desktop file which will be in either:

  • /usr/share/applications/APPNAME.desktop
  • ~/.local/share/applications/APPNAME.desktop
  • or somewhere else, use locate .desktop|grep APPAME

3) Open with gedit:

gksudo gedit /usr/share/applications/APPNAME.desktop

4) Change then line



Exec=gksudo -k -u root APP_COMMAND

5) Save

This command will also keep your environment which is very usefull if you need to connect to others servers and use your private key.

To add a quicklist option to 'Run as root'

Follow steps 1, 2 and 3 above

If the launcher currently doesn't have any other quicklist options, just append this to the end of the document


[Runroot Shortcut Group]
Name=Run as root
Exec=gksudo -k -u root APP_COMMAND
share|improve this answer
Why is it so extremely complicated to set a simple Shortcut ? What wrong with the creators of ubuntu ? – Sliq Dec 13 '12 at 9:36
I did step 1-5 and application asks for password, but won't launch. – user1880405 Aug 18 '14 at 8:57
for gksudo command, you have to install sudo apt-get install gksu – Arul Jul 8 '15 at 16:30
@Sliq its called security... Having a desktop icon that is executed as root without needing a password... is very dangerous... To me this is actually the joy of linux... If i wanted an easy life.. i would be using windows as my main system... – Mayhem Mar 3 at 1:03
I thought the point of Ubuntu was to make things easy. There seems to be an inconsistency dilemma. I have a hard time taking this distro seriously because of it. – Nuzzolilo Mar 28 at 19:55

In the Main Menu under System, Preferences, type gksudo in the Command field of Launcher Properties, e.g.:

/usr/bin/gksudo /usr/bin/yourapplication

Your Name field might say:

sudo yourapplication

So users know they may see a password popup and why...

I am not sure about Unity Launcher vs Main Menu. Maybe this helps?

Good luck

share|improve this answer
You probably know that straight sudo shouldn't be used to run graphical applications as root--after all, you are using gksudo (which is one of the good ways). For the same reason, it is inadvisable to use sudo in the name field the way you have, because doing so (1) creates the impression among sufficiently experienced users that your launcher is incorrectly made, and (2) creates the impression among less experienced users that it is OK to use straight sudo to run graphical applications as root. – Eliah Kagan Jun 25 '12 at 0:23

The following seems to do the same thing, without needing private attributes:


[Desktop Action Runroot]
Name=Run as root
Exec=gksudo -k -u root APP_COMMAND

[Desktop Action Another]
Name=Another action
share|improve this answer

As a quick and simple alternative to the cumbersome demands described in the answers here, I've gotten in the habit of doing the following...

  1. Launch a new terminal.
  2. Enter gksu nautilus

    (sudo -i nautilus works, too.)

The resulting window falls under the sudo umbrella, so you can use it to access and launch files with sudo-root privileges to your heart's content until it closes. This comes in handy for transitory situations where you don't need a more permanent solution. I use it routinely to extract compressed files into protected system folders, for instance.

share|improve this answer
Using sudo with graphical applications is NOT a good idea. Use gksu or if you must sudo -i. – Seth Feb 20 '14 at 17:05
@Seth: Updated. Also... A little explanation as to why would not be remiss, rather than just cryptically saying it's not a good idea. – Syndog Feb 20 '14 at 19:34
An interesting thread on the topic : – Syndog Feb 20 '14 at 19:47
here:… – Seth Feb 20 '14 at 20:36

Im posting this in-respone to the question @Chris asked in comments :

Suppose you want to create a launcher which will open "file manager(nautilus)" as root. Then you can do this:

  1. open terminal. Type: sudo gedit /usr/share/applications/nautilus_root.desktop

    Hit enter. When asked, enter your login password and hit enter. This will open gedit(text editor). Now, paste the following there:

Exec=gksu nautilus

Now, just save it and exit. You are done. Now if you search on dash then you will find a new launcher "Nautilus (Root)". Clicking this will ask you password, and upon authentication nautilus will be opened as root.

Note: Be careful when you are running "Nautilus (Root)". In this mode you can delete almost anything from /

share|improve this answer

This should perhaps be a comment on Daniel's solution. It works for me, even in Ubuntu 15.04. I had to put the command between quotes Exec=gksu "nautilus --new-window" because of the extra argument. Also, somehow, I don't know why, I had to edit the launcher directly in order to keep the original menu (together with the new option). If you drag your own launcher, it will get registered, but you will not have the same menu.

In Ubuntu 15.04, the launcher for nautilus is usr/share/applications/org.gnome.Nautilus.desktop. You have to use the command line to see the real file name.

Further research lead me to what I believe is a better option : . Instead of opening Nautilus entirely as Root, this allows you to open selected directories as Root within Nautilus. Anyway, I checked, and these two options are compatible. If you open Nautilus as Root and then use the second option to open a directory as Root, it simply opens it without asking the password.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.