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

How can I make a bash script executable by double clicking just like .exe files in Windows? I tried creating a launcher and assigning the script to it, but there are two consequences:

  1. the terminal twinkles, disappears, and nothing is done.
  2. you must specify to run in terminal in order to work.

I have a script that installs tomcat on an offline PC, including all dependencies of tomcat in the script. I need to make the script work on double clicking like windows since most who use the script will not be familiar with Ubuntu.

Forget the above explanation. I want to make a script that can be run by double-clicking on it, without using the terminal. Anybody knows how?

share|improve this question
I think you may just be writing your desktop file poorly. Can you post (verbatim) the .desktop launcher that you wrote? – Jjed May 18 '12 at 15:25
Also, have you seen this? – Jjed May 18 '12 at 15:27
Its just a launcher where you assign name and command to do its not that big idea – user61928 May 19 '12 at 6:38
Also note, that scripts in linux are not called bash but shell afaik. – cauon Oct 5 '12 at 8:58
muru tipped me off to this, worked for me:… – draoi Nov 16 '15 at 23:56

I tested this and it worked fine. Ensure your script begins with the correct hash-bang, e.g. #!/bin/bash

Then follow these steps:

Hit Alt+F2, type dconf-editor and hit Enter.

In dconfg-editor goto: org ➤ gnome ➤ nautilus ➤ preferences

Click on executable-text-activation and from drop down menu select:

launch: to launch scripts as programs.


ask: to ask what to do via a dialog.

Close dconf-editor. Thats it!

Source: How do I run executable scripts in Nautilus? Answer courtesy of Basharat Sial.

share|improve this answer
This worked great. Just a note, the "drop down menu" is reached by clicking on the value listed to the right of executable-text-activation (default value is display). – ryanjdillon Aug 14 '13 at 10:50
this should be the correct answer I guess – Felipe Almeida Aug 30 '13 at 3:35
for those who cannot call the app, you need to install it first with sudo apt-get install dconf-editor – whale_steward Mar 14 '15 at 6:35
This works everywhere except on the Desktop. How can I make it work on the Desktop as well? I'm using Xubuntu 14.10. – shrx Mar 28 '15 at 17:17
Is there a way to do this in LXDE (for Lubuntu)? – childofsoong May 2 '15 at 20:05

On the newer versions, on nautilus (files), go to Edit > preferences > Behaviour tab > and change the settings for executable text file.

share|improve this answer
This was by far the simplest for me – Ryan Knell Aug 4 '15 at 10:49
This works like a charm – Naga2Raja Jan 27 at 0:50

In Ubuntu and all Unix based OSes, afaik, nothing is set as executable by default. There are two ways of doing this.

  1. Right click on the script or file you want to execute. Go to Properties then to the Permissions Tab. Click the check box that says Execute.

  2. Open a Terminal cd into the directory where the file is found. Type chmod ugo+x filename. This will set the file to execute.

Now your users can double click to their hearts content.

share|improve this answer
It still will ask you what to do with run in terminal or display or run ... So its not what i need – user61928 May 19 '12 at 6:34

You have to check 3 points :

share|improve this answer

I think creating a *.desktop file is missing here:

$ cat shortcut-for-my-script.desktop
[Desktop Entry]
Exec=gnome-terminal -e "bash -c './;$SHELL'"

If you create more than one *.desktop file for one script you are able to create multiple configurations by passing different parameters, which is a very comfortable and user-friendly way.

share|improve this answer

When you create a launch in Desktop to a SHEL script or Whatever, in command line, don't forget to signal the script, to be executed in background.

The script will die when he finished is job.

share|improve this answer
i did that but what prob is the terminal just twinkles and nothing happens – user61928 May 19 '12 at 6:36

Based on umask defualt value, you haven't execute permissions for files by default and must change mod to gain execute permissions, something like this:

chmod u+x filename
share|improve this answer
Broth Ali sure i did it its obvious to do that – user61928 May 19 '12 at 6:35

Specially for Android Studio You can follow my original answer here:

To Create Desktop Launcher:

  • Click on Create Desktop Entry.. from Tools menu.

enter image description here

  • It will be prompt for password, enter password of your current login.

  • Finally it will be display notification in Android Studio screen like:

enter image description here

  • You can see in Applications => Programming => Android Studio, and you may see on desktop also after restarting system.

Thank you. :)

share|improve this answer

Your Answer


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