21

I have tried right clicking on the file selecting properties and then the permissions tab and setting it to execute. However, when I double click the file it opens in gedit. What do I do?

terdon
  • 100,812
KlingL
  • 357
  • Is this for sure about Nautilus? Could be XFCE / Thunar too. Or the file could be mounted with noexec? Or does Nautilus even respect noexec mounts? – Xen2050 May 14 '14 at 02:03
  • 1
    @bain I looked at that before I posted this question. I tried that solution before and it didn't work. – KlingL May 14 '14 at 02:34

2 Answers2

31

To run your script by double clicking on its icon, you will need to create a .desktop file for it:

[Desktop Entry]
Name=My script
Comment=Test hello world script
Exec=/home/user/yourscript.sh
Icon=/home/user/youricon.gif
Terminal=false
Type=Application

Save the above as a file on your Desktop with a .desktop extension. Change /home/user/yourscript.sh and /home/user/youricon.gif to the paths of your script and whichever icon you want it ot have respectively and then you'll be able to launch by double clicking it.


Specifically, for your situation, you need to do:

  1. Create a script that runs mono LOIC.exe. To do so, create a new text file with these contents:

    #!/bin/bash
    mono /home/logan/.loic/LOIC.exe
    

    Save this as /home/locan/run_loic.sh and then run this command to make it executable (or right click => properties and choose "Allow executing file as program"):

    chmod +x /home/logan/.loic/LOIC.exe
    
  2. Create a .desktop file that launches that script. Create a new text file on your Desktop called run_loic.desktop with these contents:

    [Desktop Entry]
    Name=Run LOIC
    Comment=Run LOIC
    Exec=/home/logan/run_loic.sh
    Icon=
    Terminal=false
    Type=Application
    
terdon
  • 100,812
  • The first bit of this doesn't work for me (Mint 18.3). The second bit is incomprehensible: what is loic.exe (searching suggests it's some sort of hacker's tool), and why is it necessary for the OP's "specific" situation? (the OP's situation looks about as generic as they get to me). – mike rodent Dec 25 '19 at 12:23
  • @mikerodent I have no idea. it seems completely generic to me too. I don't remember anymore (it's been several years). Maybe this question was merged with another and my answer was for the other one? Anyway, the second bit is using loic as an example, just make the .desktop file and point it to whatever you want it to run. If that doesn't work, ask a new question, but on [linux.se] since Mint is off topic here. But please also check the answers on the duplicate: https://askubuntu.com/questions/138908/how-to-execute-a-script-just-by-double-clicking-like-exe-files-in-windows – terdon Dec 25 '19 at 14:16
15

File Manager > Edit > Preferences > Behaviour forExecutable Text Files. In Ubuntu it is set to View Executable Files when they are opened

i prefer set it to "Ask each time" like the previous version of ubuntu.

  • this should be the accepted answer for Ubuntu 16 with Unity 7. – Alex Jan 26 '17 at 21:23
  • This is the correct solution, not the accepted one. – Mark Jeronimus Nov 16 '19 at 09:13
  • 1
    In Linux Mint 18.3 with "file manager" == Nemo, all I can say is that this does not solve the problem: after double-click you are presented with a dialog where you have to choose: Run in Terminal / Display / Cancel / Run. Aslo, setting Executable Text Files to "Run executable text files when they are opened" (instead of "Ask each time") FAILS: click/double-click then results in NOTHING happening. Other Ubuntu-based system may working differently of course. – mike rodent Dec 25 '19 at 12:12
  • @mikerodent I have your exact same issue on Ubuntu 19.1 (updated from 18.4) – Sebastián Vansteenkiste May 21 '20 at 14:16