I compiled a simple .c file using the cc command, the file was
compiled successfully and executable file (a.out) was generated.
But When I executed the a.out file it gave me:
bash: a.out: command not found
Can anybody tell me what's the problem.
Note that I'm using:
Red Hat Linux release 7.2 (Enigma)
Kernel 2.4.9-31 on an i686
And I tried the same code before on a UNIX system and it worked perfictly.
I might suspect the "typo error" here you may run ./a.out instead of a.out. Linux only searches $PATH to run applications, if the directory is not specified.
It's because the shell searches only the directories specified in the PATH environment variable when you try executing a file. Since "." (the current directory) was no where to be found in the $PATH variable, it did not check your current directory to execute it. So, every time you need to execute some command from your current directory (which is not there in the $PATH), you need to do it as killerserv said ./cmd, or simply add the following line in your $HOME/.profile