Shell Script is nothing but a group of commands written in a file to execute together. Some of the Linux software bundles come with shell script files such as “installer.sh“. You can run the .sh file in two ways. In this article, I am going to explain step-by-step how to run shell script in Linux. So let’s dive in.
How to Run Shell Script in Linux
As I mentioned in the introduction, there are two ways to run .sh file in linux. Let’s discuss one by one.
Let’s take an example shell script (.sh) file “installer.sh“. You can execute shell script using following command.
Bash: Bourne Again SHell is the GNU’s project that allows you to efficiently perform many tasks.
Following is the second way to run sh file in Linux is
Run sh file in Linux – Steps
- Open the Terminal application on Linux.
- Create a new script file with .sh extension using a text editor such as Vim.
- Write shell instructions on the file(.sh) using any text editor such as Vim.
- Set execute permission using
“chmod +x installer.sh“
- Now run the script using
“sh installer.sh” or “./installer.sh”
In this tutorial, you have learned how to run shell script in linux. If you have any doubts feel free to contact me, I will definitely try to help you. Also, you can join our elite Facebook group to get direct help from me. If you like this tutorial, please share this article on your social media handle.