VOOZH about

URL: https://www.geeksforgeeks.org/techtips/how-to-run-c-program-in-ubuntu/

⇱ How to Run C program in Ubuntu - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

How to Run C program in Ubuntu

Last Updated : 6 Mar, 2026

To compile and run a C program in Ubuntu, you need the GCC compiler, which is included in the build-essential package. After installing it, you can create, compile, and execute C programs directly from the terminal.

Step 1: Install GCC compiler on Ubuntu

  • First, update your system and install the build-essential package:

sudo apt update

sudo apt install build-essential

Verify that GCC is installed:

gcc --version

πŸ‘ version_gcc

Step 2: Create a C Program File

Use the touch command to create a new C source file:

touch hello.c

Step 3: Write a C Program

Open the file using a text editor such as Nano:

nano hello.c

Write a basic C program:


Output
Hello world
πŸ‘ helloc
πŸ‘ hello_World_program

Step 4: Compile the C Program

Compile the program using GCC:

gcc hello.c

This command generates an executable file named a.out by default.

To specify an output file name:

gcc hello.c -o hello

πŸ‘ gcc_hello

Step 5: Run the hello executable file

  • Run the compiled program using:

./hello

πŸ‘ hello_world_main

Now, we can see the actual output of Hello World in our terminal of the hello.c system file.

Also Read

Comment
Article Tags:
Article Tags: