Bash script with execute permissions won't run with double click

I have a bash script that has permission to execute, but when I double click it in nautilus it won’t execute, instead it opens as text in gedit.

In properties it says open with: gedit, and that doesn’t change when I click the reset button.

What do I have to do to make it execute? I’m running Ubuntu 13.04. I never had an issue like this one with 12.04 or with any other distribution in general.

EDIT
If I go in terminal and type: ./bashscriptname it runs just fine.

Here is Solutions:

We have many solutions to this problem, But we recommend you to use the first solution because it is tested & true solution that will 100% work for you.

Solution 1

  1. Open Nautilus.
  2. Go to FilePreferences (in Ubuntu 14.04, you might find it under EditPreferences).

    enter image description here

  3. Go to the Behavior tab and click on Run executable text files when they are opened.

    enter image description here

    Or, choose Ask each time to be prompted every time you double click.

Solution 2

As mentioned in this blog post here,

Open file explorer Files. Press Alt+F10 and select Preferences. It should show something like this

enter image description here

In the Behavior tab, select Ask each time and close it. By default, it will be in View executable text files when they are opened. Now whenever you double click on a shell script, it will ask you what to do. If you want to straight away execute the script, select the first option Run executable text files when they are opened

Note: Use and implement solution 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply