How do I fix 'bad interpreter' error messages when trying to run shell scripts?

Updated -

More often than not, this error indicates that the script in question has been written on a machine which inserted CR/CRLF's into the script (old MS-DOS style newline/linefeeds). Sometimes they appear as ^M's in the file where a newline is defined. Try running the command:

dos2unix <script name>

The command should return a prompt after it completes. Try run...

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content