I'm new using Ubuntu OS, I've Ubuntu 12.04 and I'm trying to run a simple Hello world C program

#include <stdio.h>
int main(){
printf("Hello world!");
return 0;

When using gcc --version command at cmd, it returns 4.6.3 (I think that is the version), the problem is that when I try to use the command gcc helloworld.c in the address where the helloworld.c file is, it doesn't prompt anything, not the hello world! printing nor an error, the cmd just change line like if the enter key was pressed, but it appears that an a.out file were create by the command.

I've been working with python in the same way by using python file.py command and have no problem, what am I doing wrong?

Thanks for reading!

marked as duplicate by psusi, andrew.46, David Foerster, Eric Carvalho, chaskes Apr 27 '16 at 1:13

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


When write programs in C, you must compile the program with a compiler (here gcc). So you get an executable file (here a.out).

you should give that file execution permissions with the following command:

chmod +x a.out

and then run your compiled program with

  • Do I've to give execution permissions everytime I write a new code? Thanks you solved my problem! :) – Esteban Apr 26 '16 at 2:01
  • 1
    gcc already marks the file as executable. – psusi Apr 26 '16 at 2:28

You can also customize the output file by using gcc <sourcefilename> -o <destinationfilename>

Note: you can even dump the output file in a different folder by including the path in the file name. Ex

gcc mysource.c -o ./myfolder/mybinary.out

This will create a file named mybinary.out in the folder, myfolder, within your current working directory. ./ is short had for the current working directory.

Not the answer you're looking for? Browse other questions tagged or ask your own question.