When I double-click on a script in Nautilus to run it, the script just opens in my text editor with no option to run it. Using Nautilus, how do I run executable text files and/or scripts?
14 Answers
Open Nautilus.
Open this from the menu bar:
Edit → Preferences
Select the 'Behavior' tab.
Select "Ask each time" under "Executable Text Files".
- Close the window.
- Right click the file, and select "Properties.
Select the "Permissions" tab, and make sure "Allow executing file as program" is selected.
Close the window.
Now you can double-click your executable text file in Nautilus to be asked whether to execute or edit your script.

Answer credit: Nur
- 167
- 73,717
Follow these steps:
- Install
dconf-editorbecause it isn't installed by default. - Hit Alt+F2, type
dconf-editorand hit Enter. In
dconfg-editorgoto:org➤gnome➤nautilus➤preferences
Click on
executable-text-activationand 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!
- 17,371
- 24,156
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;
- install (if you haven't already) and start dconf Editor,
- go to: org > gnome > nautilus > preferences, and
- 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.
- 11,074
in a terminal
gsettings set org.gnome.nautilus.preferences executable-text-activation ask
- 271
Using GUI
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
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.
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.
- 17,371
- 28,986
In Nautilus 45.0+, try this steps
- Create desktop file at ~/.local/share/applications
[Desktop Entry]
.....
Exec=bash %f
Name=Script_launcher_1
NoDisplay=true
Terminal=true or false
.....
- Create bash script file and make it executable
#!/bin/bash
# with or without shebang line
write commands
.....
In Nautilus, right-click the script file, click "Open with", select the created desktop entry name in the list, and check "Always use for this file type".
You can then run the script file by double-clicking it in Nautilus.
To target specific file extension, for example *.ext1, try this steps also.
- Create XML file for MIME type definition in
~/.local/share/mime/packages/my-custom-mime-types.xml
or
/usr/share/mime/packages/my-custom-mime-types.xml
<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
<mime-type type="my-custom-mime-types/custom-ext1-mime-type">
<comment>My Custom EXT1 MIME Type</comment>
<glob pattern="*.ext1"/>
</mime-type>
</mime-info>
- Update MIME database using one of following command
update-mime-database ~/.local/share/mime
sudo update-mime-database /usr/share/mime
- Result file is as follows
~/.local/share/mime/my-custom-mime-types/custom-ext1-mime-type.xml
or
/usr/share/mime/my-custom-mime-types/custom-ext1-mime-type.xml
Additional MIME types can be added to the my-custom-mime-types.xml file, then run the 'update-mime-database' again. For more details, see https://blog.robertelder.org/custom-mime-type-ubuntu/
- 61
- 4
For that I guess the best way will be to make .desktop launcher, make that launcher executable using
chmod +x blah.desktop
And after that you will be ready to run it via just clicking, and even more you can add it to launcher. To read more about how to make .desktop files look here. Main part of it is this
[Desktop Entry] Type=Application Terminal=false Icon=/path/to/icon/icon.svg Name=give-name-here Exec=/path/to/file/executable
You can do this for a single file by going into permissions in file properties and selecting "run this file as an executable".

- 36,350
- 203
You can use the most upvoted answer in Fedora 20 + GNOME too:
Open Nautilus, check Preferences -> Behavior -> Executable Files, put as always ask
- 373
The option to run a script by double-clicking it has been removed from Nautilus as of late 2020, following this bug report, enforcing the alternative #2 described in the bug report (right-click the script / click on "Run as a Program" from the context menu) as the only mean to run a script directly from Nautilus (the script must still be executable in order for this to work).
As a workaround, you can create a minimal .desktop file that will run the script, so that by double-clicking the desktop file the script will be run (again, the script must be executable in order for this to work):
[Desktop Entry]
Version=1.0
Name=Script
Exec=/path/to/script.sh
Type=Application
After that, right-click on the .desktop file and click on "Allow Launching" from the context menu.
- 41,268
Add a .desktop file to ~/.local/share/applications/
[Desktop Entry]
Exec=bash -c 'bash "%f"; $SHELL'
Name=Bash Launcher
Terminal=true
Type=Application
MimeType=application/x-shellscript;text/x-shellscript;
Icon=utilities-terminal
And add it as the default app for sh files (Right click > open with...)
- 518
You have to check 3 points :
- Nautilus / Nemo configuration : https://askubuntu.com/a/286651/301025
- The script file must have executable permission : https://askubuntu.com/a/275714/301025
- The file system must allow execution :
- Type "mount" in a console
- Check if your file system has noexec flag
- Remove noexec flag in editing /etc/fstab and
right click on the file -> open with -> other application -> view all applications -> run software -> select
from now on shell scripts will be run on double click.
- 765
Open Nautilus. (File Browser)
In Ubuntu 17.04, now we can cummulative bar so Preferences in available in Files.
Open this from the menu bar:
Files → Preferences
Select 'Behavior' tab
Select "Ask what to do" under "Executable Text Files".

Close it.
- 207,228
