How to run home-made programs?

I used g++ to compile a simple "Hello world" C++ program. It produced the "a.out" executable. If I try to run the "a.out" executable, I get "Command not found". How can I run my home-made programs?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

The "Command not found" error is because your program is in a directory not located in your path. You can remedy this by adding the directory of the file to your path or just put a './' in front of your executable file. So as long as your file is executable, you can do this "./a.out" (w/o the quotes) and the program should run.

In case your file is not executable, just "chmod 777 a.out"

If you still have problems, please leave a comment. Thanks.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
If the ¨.¨ directory is not in your path, you're probably running it as root. This is not recommended.
Content-Disposition: form-data; name="notify"

Content-Disposition: form-data; name="Submit"

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.