2

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

1
  • 1
    I removed the C++ tag because this applies to all executables. Commented Aug 14, 2014 at 6:07

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.