You can open or run .sh file in the terminal on Linux or Unix-like system. The .sh file is nothing but the shell script to install given application or to perform other tasks under Linux and UNIX like operating systems.
The easiest way to run .sh shell script in Linux or UNIX is to type the following commands. Open the terminal (your shell prompt) and type the command.
You can run the .sh file using the following syntax
- Set execute permission on your script:
chmod +x script-name-here.sh
- To run your script, enter:
The syntax is:
.sh File As Root User
Some time you need root access to install application; without root, you won’t have the necessary permissions to install application or make system level modifications. Root access is disabled by default on many Linux and UNIX like systems. Simply use the sudo or su command as follows:
sudo bash filename.sh
Type your password. Another option is to use the su command as follows to become superuser:
Type root user password and finally run your script:
chmod Command: Run Shell Script In Linux
Another recommend option is to set an executable permission using the chmod command as follows:
chmod +x file.sh
Now your can run your .sh file as follows
How do I run .sh file named install.sh?
Just run the following two command:
chmod +x install.sh
The dot (.) refers to the current working directory. The install.sh is in the current directory so you run it as above or as follows too:
GUI method to run .sh file
Firs setup executable permissions:
$ chmod +x install.sh
- Select the file using mouse.
- Next, right-click on the file.
- Select Properties submenu.
- Select Permissions.
- Select Allow executing file as a program.
- Now click the file name and you will be prompted. Select “Run in the terminal” and it will get executed in the terminal.