2

As the question asked I thought "." means the current directory so why can't we directly type helloworld to run the program?

tripleee
  • 175,061
  • 34
  • 275
  • 318
user3692521
  • 2,563
  • 5
  • 27
  • 33

1 Answers1

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
  • 1
    To 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