Skip to main content

How To Run sh File In Linux

how to run sh file in linux

As a Linux user it’s almost certain that you’ve come across a .sh file at one time or another.

It’s not a stranger to Linux operating systems. In fact, it’s entirely possible to download an application (that’s either a single file or multiple files) and when you try to open it you find that it’s a .sh type of file (example: Jad64.sh).

Well, that’s where the fun usually ends for most users because not many people know how to run .sh file in Linux. In case you are one of ‘those’ people then you’re in luck. On this page you will find a comprehensive guide on how to handle such files.

In addition to helping you understand what .sh file Linux is, we have prepared a step-by-step guide on how to run one (with cool examples) whenever you come across such files.

What is a sh file ?

A Linux file that has the .sh extension is usually a shell script that is contained in a text file. It is a program that should be interpreted by your computer’s command shell.

One of the interesting facts about shell scripts is that they don’t need to have a file name extension. You can name the file anything. But more often than not they retain the .sh extension for historical reasons. Now, having said that, any .sh file Linux can easily run with a bash interpreter regardless of how you have named it.

The best thing about .sh files is that they can run on any Linux/Unix operating system or distribution. That means you won’t need to install any additional software or (worse) use a non-Linux operating system to run the files. So how can you run these files on your Linux OS?

Read the section below to find out.

How To Run sh File In Linux

Running .sh file in Linux Operating System is fairly simple.

We are going to explain the process using JDownloader as an example. Feel free to download any .sh file from the internet for the purpose of this guide. If you wish to use JDownloader then download it from the link below:

Note: We Have used Ubuntu Ubuntu operating system for this tutorial. Don’t Worry, if your machine is not running on Ubuntu, you can use any other Linux-based operating system.

Step 1

  • After downloading the JDownloader or your own .sh file, save it on the desktop. Now rename it and give it a short name that won’t be a hassle when you need to type it in your computer’s Terminal.We have renamed it as “jd.sh”.
copy sh file to desktop
  • From the screenshot above you can see that we have renamed ours to “jd.sh”. Renaming is not extremely important but it will make your work easier when you get to the part where you have to type it in Terminal.

Step 2

  • Now open Terminal from Dash or press CTRL+T and enter the following code.

cd Desktop

  • Press “Enter” to access your desktop directory. Below is an image that illustrates this step:
open terminal

Step 3

  • Use the “chmod +x” command to give the computer permission over the .sh file. You can do that by combining that code (chmod +x) with the file name of your .sh file. In our case the file is named “jd”. So our command is:

chmod +x jd.sh

run chmod command
  • Remember that if you renamed your file to a different name from “jd” then you will type that name in place of “jd”.

Step 4

  • Now use the “sh ./” command to run the file. The purpose of this command is to run files, and that’s exactly what it will do here. Since we renamed our .sh file to “jd”, our command for this step will be:

sh ./jd.sh

run sh file
  • Again, remember to replace “jd” with the file name that you chose (in case you didn’t rename the fiel to “jd”).

Step 5

  • After entering the above command the application installer will run. The image below shows JDownloader has now started to install.
install jdownloader
  • At times it prompts you to first install some dependencies like JAVA or any other. If that occurs simply install the dependencies and run the .sh file again using the same process outlined above.

A Simple Trick – .sh File and Root Access

Sometimes when you try to run a .sh file you may get a notification that you don’t have the root permission to complete that process. Without root, you can’t access or run the .sh file. To solve that issue simply type the command below and press “Enter”.

sudo chmod +x your_filename.sh

After entering the command you will be prompted to enter your root password. Do that and proceed to run the .sh file.

Conclusion

That’s pretty much everything there is to know about How To Run sh files In Linux.

Do you still have any questions, or suggestions for improving the article? Leave a comment in the interactive section under this post and we will incorporate your ideas in this and many more articles on our website.

Feel free to browse around for more Linux-oriented tutorials.

You can check Best Linux Mini PC for your home from here >>Best Linux Mini PC<<

And also, check the best Linux gaming distro from <<<Here>>>


Comments

1
Leave a Reply

avatar
1 Comment threads
0 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
1 Comment authors
abc Recent comment authors
  Subscribe  
newest oldest most voted
Notify of
abc
Guest
abc

Why the ‘sh’ at the start of the command? If the file is executable, and your already in a command shell, what is the benefit of running another shell?