Shell script error – bad interpreter messages and solution

. I have downloaded some shell script but when I try to run these shell scripts I get error bad interpreter… How do I fix this error?

ADVERTISEMENTS

A. Make sure you have required shell installed. Each shell script specifies default interpreter at top of the script. For example, consider following script:
#!/bin/sh
# This is...
clear
A=`pwd`
...
.....
...

#!/bin/sh is default interpreter to execute this script. Use ls command to verify that you have /bin/sh installed
$ ls /bin/sh

If /bin/sh is not installed, use rpm, up2date or apt-get command to install required shell.

Another problem is if script was edited or written on MS-DOS platform, you will see CR/CRLF in script. Use dos2unix command to convert theses scripts to UNIX format.
dos2unix script-file-name

🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallCentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNCentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
3 comments… add one
  • gautam rampal Feb 23, 2009 @ 7:03

    thanks a lot my problem got solved, i tried all the ways when i used dos2unix it worked, I forgot that i edited the script previously in windows.

  • Cui Aug 11, 2009 @ 23:39

    where do you use dos2unix?
    I could not use it in command prompt and in unix
    is there a dos2linux command?
    thanks!

  • Mitra Oct 21, 2011 @ 9:40

    Thanks alot…it saves lot of time…

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.