How to run a .sh file in Red Hat?

Posted on

How to run a .sh file in Red Hat? – Managing your servers can streamline the performance of your team by allowing them to complete complex tasks faster. Plus, it can enable them to detect problems early on before they get out of hand and compromise your business. As a result, the risk of experiencing operational setbacks is drastically lower.

But the only way to make the most of your server management is to perform it correctly. And to help you do so, this article will share nine tips on improving your server management and fix some problem about linux, command-line-interface, shell, redhat, .

When I tried to run my .sh file in Redhat using ./

I am getting a error like

[test@tester unix_scripts]$ ./
: No such file or directory
[test@tester unix_scripts]$ 

I have also set the permission of the file with chmod 777

still the same error

Can anybody help me?

Solution :

Actually the issue was the script that i used was created in dos, so i converted my script to unix by using dos2unix command. Thanks to all for your valuable help.

You may have forgotten to put at the first line of your script:


for example:

echo Hello World  

If you try a simple shell script like the hello world example above?
does it work or not?

By the way: are you sure about SELinux context?
What does: getenforce say?
What does: ls -l say?

My best advice is try with a very simple script first so you can check every environment and context behavior.

Double check that you are in the right directory (you can view what is in the directory by typing “ls”) and the file’s name is “”. You may also want to try:

[test@tester unix_scripts]$ sh

Is in the unix_scripts directory?

Is there a file or directory that is being referenced in that doesn’t exist? Because the error could be coming from within the script, not from the execution of the script…

Leave a Reply

Your email address will not be published. Required fields are marked *