I am running Ubuntu Desktop (so, there's the graphical interface that I'm using). When I double click a '.sh' file, I was expecting it to run. However, it opened up gedit instead. I enabled the permission to execute the file, and I've tried to find a program called 'terminal' or 'bash' to execute the script with, and found nothing that looks like I could use it to execute the BASH script.

Could someone please tell me what I need to do, in order to be able to double click on a BASH script (or, at least right click and run with bash or something like that) and run it?

  • 1
    Does the script begin with #!/bin/bash or #!/bin/sh?
    – user423626
    May 28, 2016 at 3:56
  • Also there is an option, I think, in Nautilus that allows you to select what to do when opening executable text files (choose 'Ask each time').
    – user423626
    May 28, 2016 at 3:57
  • It does have '#!/bin/sh' at the beginning of the script.
    – Eliter
    May 28, 2016 at 5:12

1 Answer 1


You need to mark it as an executable, you can do so by right-clicking on the file then click Properties > Permissions > Then check the box next to allow executing file as program. Then it should ask you to run it or view it if you double-click on it. If not you you should look at what @bharadwaj-raju said. If all else fails you can open a terminal by hitting Ctril + Alt + T and cd-ing into the directory. If you don't know how have a look at this: https://help.ubuntu.com/community/UsingTheTerminal then run sudo chmod +x NameOfFile.sh then run ./NameOfFile.sh (Replace NameOfFile.sh with the name of your file.)

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