~ $ a.out

a.out: command not found

Why does a.out not run?

It appears there is a gcc because

~ $ gcc

gcc: no input files

Following instructions I found here:


I created a file called hello.c

#include <stdio.h>
void main ()
    printf("Hello World");

Back in the terminal I typed:

~ $ gcc hello.c

~ $ ls

a.out hello.c

~ $ a.out

a.out: command not found

I looked at the properties of a.out and it does have a checkmark for executable. So what am I missing? Is there some guru out there that can help me get off the ground with gcc? Thanks for reading.

1 answers, votes, 3958 views
hugs's picture
asked by hugs
4 years 29 weeks ago

1 Answers


You cannot simply type the name of the executable file 'a.out', which will return:

a.out: command not found

You are required to prefix the executable file with a path in order for it to run (don't ask me why).

~ $ ./a.out


~ $ /path/to/directory/a.out

Then you get:

Hello World

It took me a couple of hours to find this out. I hope this will save others some time. It's really cool to know that a functioning gcc compiler is already included in Ubuntu.

gcc page: http://gcc.gnu.org

hugs's picture
answer by hugs
4 years 29 weeks ago
  • A more convenient solution is to include the current directory in your PATH:


    - Visitor 4 years 29 weeks ago
  • linux goes by the PATH no matter where you are to keep things simple. So, if you want to execute a command in current directory you have explicitly say
    ./command or /path/command

    - Visitor 4 years 29 weeks ago
  • Have a question or want to discuss an idea about Chromecast? checkout chromecast forums

    Ubuntu 13.04 released!

    Ubuntu 13.04 code named Raring Ringtail is released download ubuntu 13.04. Download while it's hot!!

    View in your own language!

    Stay Connected

    Ubun2.com on Facebook Ubun2.com on Twitter RSS Feeds


    Favorite desktop environment?: