After reading an answer on how to make a file run a command in the terminal when ran, I tried to do it myself.

I made a new document, entered the following and saved.

#! /bin/bash

echo "this is a test"

I then went to Right-Click > Properties > Permissions and checked "Allow executing file as program."

However, when I double-click the document, it simply opens in my text editor (which I believe is gedit). In the right-click menu I see no options for running the file in the terminal.

I've tried doing this with other files as well. For instance, I installed WINE and tried to install a Window's program. WINE said to simply run the installer, but nothing would happen when I tried. I marked it to run as a program and still it wouldn't work. I could only install it by Right-Click > OpenWith and selecting WINE.

Strangely enough, I copied my Keepass-2.28 Portable folder from my Windows partition to my Ubuntu partition and tried running the executable. Keepass fired right up, even though I hadn't marked that file to run as a program. I have Keepass 2.25 from the repository installed on my system if that makes a difference.

I've been running Ubuntu 14.04 in a dual-boot setup for several weeks. The only thing I can fathom I did that would mess this up is I used Synaptic Package Manager to remove a package from KDE Desktop Environment in an attempt to uninstall an alternate desktop environment I installed via the terminal. I don't remember what the package was, but the only package in that category right now is appmenu-qt5. As far as I can tell, removing that package has affected nothing, and I'm pretty sure I had issues with running files as programs since I got my Ubuntu.

EDIT: I have checked, and I don't think this question is a duplicate of this question. My Ubuntu is on a ext4 partition, and it's from there I'm trying to run programs. I also haven't dealt with trying to change permissions via the terminal or anything like that, I'm just trying to make the program run when I check the option in the properties menu. Please correct me if I'm wrong or missing anything.

  • @muru I don't think so. I've explained in an edit.
    – Trae7
    Commented Mar 13, 2015 at 10:59
  • Not quite sure what you've had in mind, but the lesson of this exercise is: it's not that simple. Not all file are programs, not all file can run as programs, not all files should be run at all, and double-clickingis often not the right way to do it, ...and so on. Commented Mar 13, 2015 at 11:07
  • @mikewhatever I understand that. I'm not attempting to run a .png or something like that as a program. Rather, I'm trying to follow the instructions in the question I linked to at the start of the post, and it's not working. The file isn't running as the answer specified it would.
    – Trae7
    Commented Mar 13, 2015 at 11:13
  • In the file browser's Preferences (Edit->Preferences), there should be an option dealing with opening of executable files. Is it set to ~ view?
    – muru
    Commented Mar 13, 2015 at 11:20

3 Answers 3


Help in Right-Click > Properties > Permissions explains this behavior:

If the file is a program, such as a script, you must select Allow executing file as program to run it. Even with this option selected, the file manager may still open the file in an application or ask you what to do. See Executable text files for more information.

The default action when double-clicking a script is to open it in the editor. To change this option:

  1. Click Files in the Launcher, select Edit > Preferences and then the Behavior tab:

    enter image description here

  2. Select the default action when opening an executable text file:

    • Run executable text files when they are opened
    • View executable text files when they are opened
    • Ask each time

"Ask each time" is probably the right setting here, as you certainly don't want to accidentally execute a script when you just want to open a text file, especially since executable and non-executable text files share the same icon.

  • I now get a prompt when I double-click the file allowing me to run or view it. Many thanks!
    – Trae7
    Commented Mar 13, 2015 at 12:35

I suspect that you need to change the settings for the file manager so that it will either run the bash script directly, or ask you if you wish to run the script or display the code.

I don't know if the current version of Ubuntu's file manager works the same way, but a couple of years back, the fix was as follows:

"Open the Nautilus file manager and click on the gear wheel (Location Options) in the top-right corner of the window. Navigate to Preferences – File Preferences – Behaviour – Executable Text Files. A set of radio buttons allows the default option to be set. My preference is for “Ask each time”. Then, when I double click on a script file, I am given the option of either running the script or displaying (editing) its contents."

(See: https://linuxnorth.wordpress.com/2013/11/02/running-bash-scripts-in-ubuntu/)


Edit: This solution will work for single files, but if you're looking after changing this behavior system-wide (i.e. for every executable text file), check out the other answers.

You'll need to create a .desktop file in order to run the script straight from Nautilus:

  1. Create a .desktop file on the desired location: gedit /<path_to_dektop_file>/test.desktop
  2. Paste the code below
  3. Save
  4. Exit
  5. Make the file executable: chmod u+x /<path_to_dektop_file>/test.desktop


[Desktop Entry]

Then just double-click the .desktop file created.

  • Nice solution but it doesn't escalate well as it requires a desktop file for every single script you want to run from Nautilus.
    – jaume
    Commented Mar 13, 2015 at 11:35
  • 1
    @jaume True, i clarified it
    – kos
    Commented Mar 13, 2015 at 11:40

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