How do I run .sh scripts?
Whenever I open a .sh file, it opens it in gedit instead of the terminal. I can't find any option similar to Right Click → Open With → Other Application... → Terminal.
How do I open this file in the terminal?
Solution 1:
Give execute permission to your script:
chmod +x /path/to/yourscript.sh
And to run your script:
/path/to/yourscript.sh
Since .
refers to the current directory: if yourscript.sh
is in the current directory, you can simplify this to:
./yourscript.sh
Solution 2:
You need to mark shell scripts as executable to run them from the file manager:
-
Right click on your
.sh
file and select Properties: -
In the Permissions tab, check Allow executing file as program:
-
Close the Properties window and double-click the file. A dialog will pop up giving you the option to run the script in a terminal:
Solution 3:
Open a terminal and navigate to the folder where the .sh
file is located. Then type:
sh <name of file>.sh