Sign up ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

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

6 Answers 6

up vote 43 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 at 16:30

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

Here is how to start Nautilus as root from Unity in Ubuntu 14.04, as an option in the contextual menu. I suggest that you do the following with a non graphical editor such as nano or vi as root. The original launcher is /usr/share/applications/nautilus.desktop. Otherwise search for it using grep. Open a new file with the name you want, read the original launcher within it and save it - that's a backup. Find the line Actions=Window; and change it for Actions=Window;Sudo; . Finally, add the following lines at the end

[Desktop Action Sudo]
Name=Open a New Window as Root
Exec=gksudo -k -u root 'nautilus --new-window'

Note that we must put the command between quotes. Save the file over the original file /usr/share/applications/nautilus.desktop or whatever it is in your case. That's it. You will see an extra option Open a New Window as Root.

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.