Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Possible Duplicate:
Why is . not in the path by default?

This question might be trivial but I'm wondering why I have to type the dot and the slash before the name of my script in order to execute it, even though it is located in my current directory.

./my_script.sh

Whenever I type it without the dot & the slash:

my_script.sh

I just get -bash: cloud_sync.sh: command not found

What is the reason behind putting the ./ in front of a script name?

Thanks.

share|improve this question

marked as duplicate by Nifle, Bobby, Joey, KronoS, Diogo Oct 31 '12 at 13:56

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
Thanks! I think this already answered my question. –  beta Oct 31 '12 at 13:52
    
I am late to the party, but you can symlink (ln -s /path/to/orig.sh /usr/bin/orig) it to your /usr/bin folder from your scripts directory (/usr/bin is in your $PATH) and then you can just type my_script (it even tab-completes). –  nerdwaller Oct 31 '12 at 14:06

1 Answer 1

up vote 1 down vote accepted

You need to have your current directory in your PATH, export PATH=${PATH}:.

share|improve this answer
2  
Note that having your current directory in your path is considered a security risk. There is a good reason this is not the default on multi-user systems. –  Hennes Oct 31 '12 at 16:04
    
a better way would we to put user scripts to ~/bin and add this to your PATH variable. –  l1zard Nov 1 '12 at 22:41
    
I added current directory as the last path since it's somewhat safer then have it first. The best is of course to be explicit and have them in ~/bin. –  Jimmy Hedman Nov 14 '12 at 14:05

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