This question already has an answer here:

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?

marked as duplicate by muru, chaskes, Terrance, Videonauth, mchid May 28 '16 at 4:37

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.

  • 1
    Does the script begin with #!/bin/bash or #!/bin/sh? – UniversallyUniqueID May 28 '16 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'). – UniversallyUniqueID May 28 '16 at 3:57
  • It does have '#!/bin/sh' at the beginning of the script. – Eliter May 28 '16 at 5:12

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.