How To Run .sh Script File in Linux

This post will guide you how to run .sh file to install a software application from the command line in your Linux operating systems. How to execute a shell script .sh file on your linux console.

how to run .sh file linux5

Run .sh Script File


.sh file is a shell script file, and you can run it from the command line. you can type the following command to run it:

$ ./shellScript.sh

Or

$ sh shellScript.sh

Or

$ bash shellScript.sh

Note: before executing the shell script, and you need to give executable permission to your .sh script by running the following chmod command:

$ sudo chmod u+x shellScript.sh

Run .sh Script File as Root User


If your .sh file need root permission for executing in your system, and you can use sudo or su command to run it, type:

$ sudo bash shellScript.sh

Or

$ sudo sh shellScript.sh

Or

$ sudo ./shellScript.sh

Run .sh Script Via GUI


You can also run a .sh script from your Linux GUI interface, just do the following steps:

#1 navigate to the directory that containing your .sh script file from Files management system.

how to run .sh file linux1

#2 right click on your sh script file, and select Properties from the context menu list. And the Properties dialog box will open.

how to run .sh file linux2

#3 switch to Permission tab, and select Allow executing file as program checked box. Closing the Properties dialog box.

how to run .sh file linux3

#4 Open Applications -> Accessories -> Terminal, Drag and drop the .sh file into the terminal and press Enter key on your keybaord

how to run .sh file linux4

Conclusion


You should know that how to run a .sh script file to install a software from the command line or GUI on your CentOS or RHEL Linux system.

You might also like:

Sidebar



back to top