This question already has an answer here:

I'm using Ubuntu 18.04 but my .sh files will not execute they just open up in gedit. I have tried changing what the file opens with but Idk which application to choose from the list.

marked as duplicate by user535733, karel, muru, Sergiy Kolodyazhnyy, Pilot6 Jul 7 '18 at 7:48

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • If you are referring to executing scripts from the file manager, then see Ubuntu 18.04 executable not executing – steeldriver Jul 5 '18 at 0:56
  • I looked at that and it does not help me that well, I changed the preference to Ask waht to do, but the Shell script still just opens gedit – TDSkitz Jul 5 '18 at 1:12

First, ensure your script begins with the correct hash-bang, e.g. #!/bin/bash

Then make sure the .sh file is executable -

  1. Open a terminal using Ctrl+Alt+T or from the applications menu
  2. Navigate to the location of the .sh file. e.g. cd ~/location/to/my/file
  3. Run
    1. chmod u+x <file name>.sh, or
    2. if permission is an issue, sudo chmod u+x <file name>.sh and enter your password to confirm
  4. Alternatively, you can right-click the .sh file from the file browser and update permissions via the Properties option

To make .sh files executable from nautilus(file browser) follow these steps:
Referring - How to execute a script just by double clicking like .EXE files in Windows?

  1. Install dconf-editor because it isn't installed by default.
  2. Hit Alt+F2, type dconf-editor and hit Enter.
  3. In dconf-editor goto: orggnomenautiluspreferences
  4. Click on executable-text-activation and from drop down menu and select:
    1. launch: to launch scripts as programs, OR
    2. ask: to ask what to do via a dialog.
  5. Close dconf-editor.

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

  • 1
    I think that in point 3 should be "dconf-editor" instead of "dconf-editor" :) – Patryk Godowski Jun 3 at 8:47

Check the permissions for the file:


If the first 4 characters of output aren't -rwx then change the permissions on the file:

chmod 744 FILENAME


Make sure your .sh files are marked as executable (have "executable" permission). This is the primary way that a lot of software uses to tell if a file is an executable you want to run or a document you want to open.

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