I am trying to create a shell script i can run from anywhere in the terminal,

the script simply echoes a message

echo "Excellent work Snake!"

I changed the scripts permissions with

chmod 775 test.sh

the script is in my documents, i made a symbolic link to /usr/bin with

ln -s ./test.sh /usr/bin

when i run the script from home for example, instead of the message echoing, nothing happens, e.g.

babbleshack@babbleshack ~ $ test
babbleshack@babbleshack ~ $ 

am i failing to understand something?


test is a bash builtin - called with no arguments, as in your example, it does nothing1.

Your shell script is not called test but test.sh, so to run it you need to type:

$ test.sh

However, that's not the only problem. Your command ln -s ./test.sh /usr/bin isn't doing quite what you think - ./test.sh is a relative path, and links to relative paths are relative to the location of the link, not relative to where you were when you typed the command.

You actually want something like:

$ ln -s /home/babbleshack/test.sh /usr/bin

... at which point things ought to work.

1 Technically, it unsuccessfully does nothing (in other words, it returns a non-zero error code). If that means nothing to you, don't worry - it's not important for the purposes of this answer.

  • when i run test.sh i get command not found error. I am going to try renaming my script – Babbleshack Aug 17 '13 at 21:25
  • I renamed my file to foo.sh made a link and i am getting a 'command not found' error – Babbleshack Aug 17 '13 at 21:30
  • @Babbleshack that probably means your ln -s ./test.sh /usr/bin failed ... do you see an entry for /usr/bin/test.sh if you type ls -l /usr/bin/te*? – user173718 Aug 17 '13 at 21:31
  • @Babbleshack are you sure that you successfully made the link? What's in /usr/bin? – user173718 Aug 17 '13 at 21:32
  • yer its there i ran ls | grep testme in /usr/bin and it shows the link – Babbleshack Aug 17 '13 at 21:34

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.