Skip to content


Solving /bin/bash^M: bad interpreter: No such file or directory

So, you just uploaded a bash script to your server, its first line is #!/bin/bash, and when you run it it stops with an error /bin/bash^M: bad interpreter: No such file or directory? You’ve probably created the file on Windows, using Windows line breaks, which apparently .sh scripts can’t handle properly. You’ll need to convert your line breaks to UNIX format. This can’t be done in Notepad (but hopefully you’re not using that), however it can be done in Notepad++, only it’s remarkably well hidden IMO. The menu item to look for is simply Edit → EOL conversion (EOL standing for end of line). Just pick the right format (it should indicate that you have Windows line breaks, just switch to UNIX line breaks).

Alternatively, you could also run dos2unix yourscript.sh right on your server, although that’s something I find in some pretty old thread, and on Debian 7 at least this dos2unix thing doesn’t seem to be installed by default.

On a side note, I encountered this issue while copy/pasting this nice anti-w00tw00t scan script from spamcleaner.org.

Posted in Linux, programming.


0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.



Some HTML is OK

or, reply to this post via trackback.

Please solve the CAPTCHA below in order to fight spamWordPress CAPTCHA