Results 1 to 3 of 3
I've compiled a c program in Linux with the following command:
gcc hello.c
When I type "a.out" and try to execute it, it says:
bash: a.out: command not found.
But ...
- 03-17-2008 #1Just Joined!
- Join Date
- Mar 2008
- Posts
- 16
[SOLVED] bash: a.out: command not found.
I've compiled a c program in Linux with the following command:
gcc hello.c
When I type "a.out" and try to execute it, it says:
bash: a.out: command not found.
But I can see the a.out file in the folder.
By searching the internet I know I can use "./a.out" to execute it.
Why do I need to use "./a.out" instead of "a.out"?
- 03-17-2008 #2
Bash tries to execute commands based on your PATH. It's an environment variable that tells Bash where to find programs. Usually your PATH points to /bin/ and /usr/bin/ and perhaps a few other directories. Bash can't find a.out in those directories, so it throws an error.
By prefacing a command with ./ you're telling Bash to include the current directory you're working in when it looks for the executable named "a.out".Registered Linux user #270181
TechieMoe's Tech Rants
- 03-17-2008 #3Just Joined!
- Join Date
- Mar 2008
- Posts
- 16
Thank you for that info!



