How do I run executable scripts in Nautilus rather than open them in Gedit text editor? [duplicate]

  1. Open Nautilus.

  2. Open this from the menu bar:

    Edit → Preferences

  3. Select the 'Behavior' tab.

  4. Select "Ask each time" under "Executable Text Files".

  5. Close the window.
  6. Right click the file, and select "Properties.
  7. Select the "Permissions" tab, and make sure "Allow executing file as program" is selected.

  8. Close the window.

Now you can double-click your executable text file in Nautilus to be asked whether to execute or edit your script.

enter image description here


Answer credit: Nur


Follow these steps:

  • Install dconf-editor because it isn't installed by default.
  • Hit Alt+F2, type dconf-editor and hit Enter.
  • In dconfg-editor goto: orggnomenautiluspreferences

    enter image description here

  • Click on executable-text-activation and from drop down menu select:

    launch: to launch scripts as programs.

    OR

    ask: to ask what to do via a dialog.

  • Close dconf-editor. That's it!


I think this is a nuisance caused by Gnome people who decided to change that default behavior we were accustomed to.

To fix it, you can;

  1. install (if you haven't already) and start dconf Editor,
  2. go to: org > gnome > nautilus > preferences, and
  3. change the value for executable-text-activation back to ask (or even launch, if you prefer).

If you want the same Nautilus behavior as Root as well you can repeat the steps above, starting dconf Editor this time as Root.


in a terminal

gsettings set org.gnome.nautilus.preferences executable-text-activation ask

Using GUI

  1. Depending on which Ubuntu version you have,

    • 14.04 or 16.04

      In Nautilus, open this from the menu bar:

      Edit → Preferences

    • 18.04+

      In Nautilus, open this from the menu bar:

      Files → Preferences

  2. Then, in the 'Behavior' tab, select "Run them" (previously "Run executable text files with they are opened").

    Alternatively, select "Ask each time" instead if you would like a dialog (example) asking you whether to edit or execute the file.

    screenshot

Using Command line

If you prefer a command:

dconf write /org/gnome/nautilus/preferences/executable-text-activation "'launch'"

Note: Both GUI and command line methods work only for Nautilus (the default graphical file manager in Ubuntu).

Originally from another answer posted by me here.