When you run commands on Linux it searches all the directories listed in the PATH environment variable, and if it doesn't find the command there then you get the message you've seen.
Typically it looks like this:
PATH=/usr/local/bin:/usr/bin:/bin
That means it will look first in /usr/local/bin. If it doesn't find it there it'll look in /usr/bin, and so on.
In fact, this is very similar on DOS/Windows: there's a variable called %PATH% that does exactly the same thing.
The difference is that, on Windows, the current directory is also searched. Unix considers this bad because a local file (such as malware) can override important system programs accidentally.
If you prefer that though, you can make Linux work the same way by adding . to the path:
PATH=.:$PATH
(That says set PATH to .: plus the existing contents of $PATH.)
It ends up looking something like this (it may be different on your machine):
PATH=.:/usr/local/bin:/usr/bin:/bin
If you'd rather not do that, you can simply run each program by specifying the directory explicitly:
./myprog
or
/home/username/myprog
sudo chmod 777 a.out– Nikoloz Shvelidze Mar 13 '12 at 19:19+xfor you; you do not need tochmodthe executable produced by a compiler. The only common situation wheregccfails to make it executable is if it's creating the file in a filesystem that doesn't support or allow it (in which casechmodimmediately afterwards would fail too). Also,777should be avoided. There is no need to make it readable, writable, and executable by all users; if it were necessary to runchmod, thenchmod +x a.outwould be sufficient. – Eliah Kagan Jul 24 '17 at 03:29