4

I recently migrated from fedora 10 to Ubuntu 14.04 and believe me it was a real challenge :)

I almost managed to work anything out but only one problem is remaining. in fedora 10 i used to create .sh file containing commands to be executed in terminal and easily run those by double clicking on .sh file.

here is the method i was using in fedora:
1- creating a file with gedit
2-typing the command in it
3- chmod u+rwx example.sh

I followed the same method in Ubuntu but it does not work. however the shell file works perfectly when I type sh example.sh . also I read somewhere to go and allow the file to be executable and choose terminal as a default program for shell script file type, but there is no terminal in that list.

1
  • Double question from [How to execute a script just by double-clicking like exe files in windows][1]. See link for answer ;-) If dconf-editor is not available please use "sudo apt-get install dconf-editor" [1]: askubuntu.com/questions/138908/…
    – keocra
    Sep 1, 2015 at 13:06

2 Answers 2

9

There's a simple method to make executable on Ubuntu; I've done so and it's worked fine.

You can either use the graphical method, by opening the properties dialog of the script, selecting permissions and Allow executing files as program.

Or you can run chmod +x yourscript.sh.

First though, make sure your file manager supports executing files:

gsettings set org.gnome.nautilus.preferences executable-text-activation ask
1
  • 3
    How do you make it so it doesn't ask. You click on it and it just executes it?
    – Steve3p0
    Jan 24, 2019 at 3:34
3

You doing everything correctly, but there's one more extra step - you need to tell the default file manager to allow running executable files.

Open the file manager and go to Edit -> Preferences -> Behavior. Check "Run executable files when they are opened" (it's under Executable Text Files).

Once you do that, you will be able to run those. Remember however, that if you actually want to see them run in terminal, you need to specify that in the script itself. For instance,

#!/bin/sh
gnome-terminal -e 'mc' &
8
  • 1
    My answer was better :P ;) askubuntu.com/a/661884/367165
    – A.B.
    Sep 1, 2015 at 13:53
  • Yes, I like the gsettings way . I didn't know there's schema for it ^_^ Sep 1, 2015 at 14:17
  • can you explain this more? ""if you actually want to see them run in terminal, you need to specify that in the script itself""? my problem is solved now and when i double click on the .sh file it ask to run in terminal and etc but when i choose terminal it can not find the program (ns2).
    – user329907
    Sep 1, 2015 at 16:52
  • @user329907 so , if you don't tell your script to output to the terminal, like I did in my answer up above, it will run in the background, doing stuff,but not showing up. As for your script: what do you mean you cannot find the program ? what exactly happens ? can you explain in more detail ? Sep 1, 2015 at 17:02
  • @serg it says ns : not found
    – user329907
    Sep 1, 2015 at 17:04

Not the answer you're looking for? Browse other questions tagged .