How to Run a .sh File in Linux

Linux Shell ScriptI’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:

  1. Open a terminal in Linux
  2. Navigate to the directory containing your .sh file using the Linux cd command
  3. Use the Linux chmod command to change file permissions of the .sh file to add execute permissions chmod u+x

Now that your .sh file has it’s file permissions changed you can run the .sh file by following these Linux steps:

  1. Open a Linux terminal
  2. Navigate to the directory containing your .sh file if you are not already there using the Linux cd command
  3. Type ./ or sh

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!

Comment Linux tutorial or Leave a Trackback

One Comment

  1. Yelinna
    Posted November 12, 2015 at 6:26 pm | Linux tutorial comment

    netbeans comes in a .sh file. In this case I simply open my terminal in the folder with the file and type:

Post a Comment

Your email is never published nor shared. Required fields are marked *