I am new to linux, and I have a shell script (.sh) file I on my Desktop that I want to run. These are the steps that I did:

This is the content of the test.sh file on my Desktop:

    echo "test"

I want to run (Execute) test.sh through the terminal. These are the commands that I'm using:

cd Desktop

I give permission to run test.sh with:

chmod +x test.sh

and then try to open the file:


But I get this error:

test.sh: command not found

and when I enter test.sh with ./ again get this error:

bash: ./test.sh: bin/bash: bad interpreter: No such file or directory

What am I doing wrong?


bash: ./test.sh: bin/bash: bad interpreter: No such file or directory





bin/bash is a path relative to the current directory. /bin/bash is an absolute path that works whatever the current directory is.

Also, have a look at your PATH:

echo $PATH

If you place test.sh in any directory listed there and you will will be able to execute it without the ./ or other path specifier. Many people create a $HOME/bin directory, place all their scripts there, and add it to their PATH.

| improve this answer | |
  • Khoda Pedar Madarat ra biamorzad (I mean God Bless you And your parents) – ahmad abedini Nov 10 '14 at 22:06

To be able to run your bash script, change first line to


That is the binary that will interpret and run your script.

To run a bash script, do the following


In your example:


in the directory where you have the script.

| improve this answer | |
  • Oh, you need to put #!/bin/bash in the beginning also. – mattias Nov 10 '14 at 22:03

I edited the .sh file on a Windows machine and saw similar issue. The issue was fixed after running dos2unix on the script.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.