How to run shell script after double click

What do you want to do when you double-click a script (.sh file)? The usual idea is to execute it. But this is not the case under Ubuntu, or I should rather say in Files (Nautilus). You might frantically yell "Run file, run file", but the file doesn't run but opens with Gedit.

I know you might say does the file have executable permissions? I would say yes. The script has executable permissions but when I double click it, it still opens with a text editor. I don't want this, and if you have the same problem, I think you might want this too.

I know you've probably been advised to run it in a terminal, and I know that works, but that's not an excuse for not being able to run it in a GUI, right?

In this tutorial, we will see how to run a shell script after double-clicking it .

Fix the way shell scripts are opened with a text editor in Ubuntu

The reason why shell scripts are opened with a file editor is the default behavior setting in Files (the file manager in Ubuntu). In earlier versions, it might ask you whether to run the file or open it with an editor. The default behavior has been modified in the new version.

To fix this, go into File Manager and click Options in the menu:

How to run shell script after double click How to run shell script after double click

Next, go to the Behavior tab in the file options and you will see the executable text file option.

By default, it is set to "Show text file on open". I suggest you change it to "Ask every time" so you can choose whether to execute or edit, and of course you can also select "Cloud executable text file when opening." You can choose.

How to run shell script after double click How to run shell script after double click

Guess you like

Origin blog.csdn.net/yaxuan88521/article/details/133547195