I’ve seen many people searching the internet looking for “run a .sh file” or “how to run a .sh file”. I’ve also had many Linux users ask me what do I do with a .sh file? Well a .sh file is a script file that you can run in bash.
How to Run a .sh File
Running a .sh file is a rather simple task in Linux. The first thing we want to do is make sure that the .sh file is executable. To do this we need to change the .sh file’s permissions. If you have read our Linux tutorial on the Linux chmod Command you should already know how to use Linux chmod command. To change the permissions of your .sh file in Linux to add execute permissions, you can follow these steps:
- Open a terminal in Linux
- Navigate to the directory containing your .sh file using the Linux cd command
- Use the Linux chmod command to change file permissions of the .sh file to add execute permissions
chmod u+x filename.sh
Now that your .sh file has it’s file permissions changed you can run the .sh file by following these Linux steps:
- Open a Linux terminal
- Navigate to the directory containing your .sh file if you are not already there using the Linux cd command
NOTE: In the first example command there is a period before the forward slash.
That is all you need to do in Linux to run a .sh file. I hope this Linux tutorial on how to run a .sh file in Linux has helped you run your .sh files in Linux easily. If you have any Linux questions or comments about this Linux how to, please do so below this Linux tutorial! Thanks for visiting Beginner Linux Turorial, remember to come back and learn about Linux!