Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Possible Duplicate:
Why do we use “./” to execute a file?

It seems redundant and gets annoying after a while -- is there a way to change this? If not, can somebody explain the reasoning behind this?

Thanks!

share|improve this question

marked as duplicate by Gilles, Caleb, camh, mattdm Jul 4 '11 at 13:45

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.

    
Aren't duplicates flagged here (it does not appear as reson in the list). Should I ask this on meta? Okay - I will do so! –  user unknown Jul 4 '11 at 10:11
add comment

3 Answers 3

You don't, if the current directory is in your path and there isn't another executable with the same name in a directory named earlier in the path. If either of these conditions isn't true, ./ effectively says "look here".

Although you can add "." to your path, it isn't advisable, since that opens the door for unexpected (or malicious) results if you execute a command from a directory that has executables that match the name of system commands.

share|improve this answer
2  
This gets especially dangerous when executing shell scripts with su privileges, since it fails to sanitize the environment beforehand. –  Shadur Jul 4 '11 at 4:09
add comment

You do if your current directory is not in your path. If you ever log in as root or are a sudoer, I do not recommend you add your current directory to your path. Just put up with the ./

If you wish, make a directory in your home directory called bin. Then add this directory to your search path. It's a good place to put your general purpose housekeeping scripts.

share|improve this answer
add comment

isnt it much easier than running your program using sh yourprogram.sh or python yourprogram.py ?

share|improve this answer
add comment

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