Ubuntu – How to execute a script just by double clicking like .EXE files in Windows


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?

Best Answer

  • I tested this and it worked fine. Ensure your script begins with the correct shebang, e.g. #!/usr/bin/env bash .

    Then follow these steps:

    • Hit Alt+F2 to run a command.
    • Type dconf-editor and hit Enter.
    • In dconfg-editor go to: 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!

    Alternative way, using terminal: Run:

    gsettings set org.gnome.nautilus.preferences executable-text-activation 'launch'

    Note: The file should be executable. You may also need to change permission of file. Right click and set "Allow executing file as program"



  • Related Question