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.

  • 1
    If you know the risk of running graphical apps as root and still want to continue then follow step 1 here: askubuntu.com/a/118483/41562 – 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

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. Then change the 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
| improve this answer | |
  • 54
    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
  • 7
    for gksudo command, you have to install sudo apt-get install gksu – Arul Jul 8 '15 at 16:30
  • 6
    @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... – Angry 84 Mar 3 '16 at 1:03
  • 3
    @sliq "Why is it so difficult to grep from cmd prompt? what is wrong with the creators of Windows?" - Creators of Ubuntu... probably – thenaglecode Jan 26 '17 at 23:30
  • 5
    outdated for Ubuntu 18.XX Can someone provide an updated solution? – JRsz Jun 18 '18 at 12:07

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

| improve this answer | |
  • 4
    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
  • 3
    Unable to locate package gksudo - Ubuntu 18.04.1 LTS – 8bitjunkie Feb 27 '19 at 15:41

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
| improve this answer | |
  • 5
    Unable to locate package gksudo - Ubuntu 18.04.1 LTS – 8bitjunkie Feb 27 '19 at 15:41

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.

| improve this answer | |

As this is an old question, with an old answer; To complement @edm's amazing explanation.

As of Ubuntu 18.04 and later, gksudo (gksu) is deprecated and so, it does not have an install candidate in the official repositories. An alternative is to use pkexec.

Edit the file /usr/share/applications/APPNAME.desktop and change the line




More details on pkexec here.

| improve this answer | |
  • this causes a password prompt but doesn't then launch the program for me. /usr/bin/nvidia-settings is the prog, FWIW. – dez93_2000 Mar 25 at 18: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:

Open terminal. Type:

sudo -H 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 / and break the system.

| 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 : http://ubuntuhandbook.org/index.php/2014/04/ubuntu-14-04-add-open-as-rootadministrator-to-context-menu/ . 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.

| improve this answer | |

To create a shortcut that executes a script with root permissions on Ubuntu 20.04, you can use:

  1. Add the following line to /etc/sudoers (sudo gedit /etc/sudoers)

    • YOURUSERNAME ALL = NOPASSWD: /script/path
  2. Create a desktop shortcut:

    • gedit ~/Desktop/myshortcut.desktop
  3. Add the following content:

    #!/usr/bin/env xdg-open [Desktop Entry] Version=1.0 Type=Application Terminal=false Exec=sudo /script/path myarg Name=Shortcut Name Comment=Shortcut Comment Icon=/usr/share/icons/Humanity/actions/16/media-playback-start.svg

  4. Right click and the shortcut and choose Allow Launching:

enter image description here

| improve this answer | |
  • Yes, interesting. But the thing will be started with sudo. What if I want to start a GUI? Since from 18.04 on gksu is gone and starting GUIs with sudo is considered bad what is the actual real thing to do it?! – Ben Jul 8 at 11:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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