how to execute a file in ubuntu by double click

Shell
#For nautilus, execute in terminal:
gsettings set org.gnome.nautilus.preferences executable-text-activation 'launch'
#Note: The file should be executable. You may also need to change permission of file. Right click and set "Allow executing file as program"
Source

Also in Shell: