Rohit Sawarkar's Blog

How to run .sh file in Linux

on September 13, 2011

Hello Friends,

In this article I’ll explain how to install .sh file in Linux.

.sh file is nothing but the shell script to install given application or to perform other tasks under 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:

sh file.sh

OR

bash file.sh

.sh File As Root User

Sometime you need to install application which requires root level privilege
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 sudo or su as follows:

sudo bash filename.sh

Type your password. Another option is to use the su command as follows to become superuser:

su –

Type root user password and finally run your script:

bash filename.sh

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

./file.sh

 

Enjoy 😀


3 responses to “How to run .sh file in Linux

  1. Yogesh Shahu says:

    Rohit Plz tell How to install the GCC, G++ or any Compiler in MAC OS…to run the *.c, *.cpp and other…?

  2. siva says:

    can you run filename.sh from terminal simple $filename?

  3. Prasad says:

    good

Leave a comment