As the question asked I thought "." means the current directory so why can't we directly type helloworld to run the program?
Asked
Active
Viewed 92 times
2
-
1I removed the C++ tag because this applies to all executables. – juanchopanza Aug 14 '14 at 06:07
1 Answers
4
Because '.'
, the current directory, is not in your environment's $PATH
, which contains the list of paths where executables get searched. To see your PATH
variable, type
echo $PATH
This is most likely for security reasons, to prevent execution of local executables named after system or other trusted installed ones. I have worked on systems where '.'
was in the PATH
and at the very least it lead to some confusing moments (the test
utility being a favourite candidate for accidental replacement.)
I would advise against appending '.'
to PATH
for those reasons.

juanchopanza
- 223,364
- 34
- 402
- 480
-
1To elaborate on this answer, not having `.` in the `$PATH` is a *good* thing. Think what would happen if there was a program named `ls` in the current directory, and you wanted to list file? Then the local `ls` program would be invoked and not `/bin/ls`. – Some programmer dude Aug 14 '14 at 05:53