Home  >  Article  >  System Tutorial  >  How to run shell script after double click

How to run shell script after double click

WBOY
WBOYforward
2024-01-06 21:17:481418browse
Introduction 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 may say that the file has 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 may have been advised to execute it under the terminal. I know this works, but is this not an excuse for not running under the GUI?

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

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 new versions.

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

How to run shell script after double click

Next, enter 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 when opening". 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


The above is the detailed content of How to run shell script after double click. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:linuxprobe.com. If there is any infringement, please contact admin@php.cn delete