.sh files are shell scripting files. We can run these files in terminal on a linux system.
Navigate to file location
Start terminal and navigate to folder where you have the shell script .sh file. If this is a server / vps, login to your server using putty.
Let’s suppose my shell script file name is my_script.sh and it is located in /root directory. Use below command to navigate to /root directory.
cd /root
Run the script file
Use the below command to run or execute the script.
bash my_script.sh
or
sh my_script.sh
Permission denied error message
If we try to run this script using below command, we will get Permission denied error message.
./my_script.sh
We first need to set execute permission to the script file and then run the script.
chmod +x my_script.sh ./my_script.sh