.sh
is an extension for a shell script. A shell script is a file that is executed directly run by the "shell". For example, a .c
file is compiled by the C compiler like gcc
, Turbo C
, etc. Similarly there are shells like bash, Bourne shell, etc which are also called as command-line interpreters which execute this .sh
file.
So, in order to run a .sh
file, you can try any of the following at the terminal
(the command-line interface) by first going to the directory in which the file is located:
1) For executing using a particular shell:
bash filename.sh
which is in your case:
bash update_java_home.sh
If you have installed Ubuntu, you should have bash by default.
2) For executing using the default shell:
chmod +x filename.sh
which is in your case
chmod +x update_java_home.sh
Here, chmod
is a command to change the file permissions. +x
gives executable rights to the user logged in, if permissible, upon the file given as filename.sh
and then
./filename.sh
Here, a .
indicates the path is the current directory and asks the shell to execute the file gives as filename.
These are perhaps the most common methods used to execute shell scripts. There may be other methods too.