How to Run C program in Ubuntu
Last Updated :
12 Apr, 2025
Learning to run a C program in Ubuntu is a great first step for anyone starting their programming journey or switching to a Linux-based system. Ubuntu offers a clean and powerful environment to write, compile, and execute C code all from the terminal.
In C, this guide will show you how to get started. From writing your first C program to compiling and running it in the Ubuntu terminal, we’ll cover everything you need in simple steps.
How to Run C Program in Ubuntu?
To compile and run a C program on the Ubuntu operating system via a file, we require the GCC compiler in our internal system. One of the build-essential packages that produces the various activities that we need to install from the Ubuntu repository is the GCC Compiler.
We must develop our C program in an Integrated Development Environment (IDE) like Visual Studio Code or a basic text editor which can compile and run all of the programs after installing the build-essential package. We must then compile and run our C program by creating a file on the terminal. Follow the below-mentioned easy steps to run and compile a C program in Ubuntu.
Step 1: Install GCC compiler on Ubuntu
- Install the GCC compiler on the Ubuntu operating system > Check the GCC compiler installation status by using the below command
$ gcc -version
Step 2: Implement touch command
- Use the touch command on the terminal > Create a C program file
$ touch hello.c
Step 3: Write a C program on the file
- Open the file named hello.c > Write a basic C program
Let's see the hello.c program -
C
#include <stdio.h>
int main() {
// code
printf("Hello world");
return 0;
}
Step 4: Compile the hello.c program
- Go to the program file > Compile hello.c file
- Use gcc hello.c command in the terminal > Generate hello executable file in the Ubuntu system terminal
Step 5: Run the hello executable file
- Use ./hello command in the environment > Run the hello executable file in the terminal on Ubuntu
Now, we can see the actual output of Hello World in our terminal of the hello.c system file.
Conclusion
For executing Linux-based applications, Ubuntu is a popular Linux-based operating system in today's technology. In addition to offering an adaptable and open-source platform for a variety of internal applications and professional industries, it allows all users to customize the system. All we need to do is write our C program in a text editor create a file, compile it, and run it in the terminal after installing the build-essential package by following the proper steps. This simple procedure enables all the users to begin using C programming in Ubuntu.
Also Read
Similar Reads
How to Compile and Run C program in Terminal? To efficiently compile and run C programs, users typically utilize a compiler or the built-in terminal. The command prompt (CMD) on Windows can be employed to process C programs and generate the desired outputs. To create an executable C program, users must compile their C code using the system term
6 min read
How to Install Turbo C++ on Linux? In this article, we will look into how to install Turbo C++ on Linux. Turbo C++ is the free and Open-Source Software, it is a development tool for writing programs in the C/C++ language. Turbo C++ is a compiler and IDE (Integrated development environment) originally from Borland. Prerequisites: To r
2 min read
How to Install Turbo C++ on MacOS? Turbo C++ is a single-language compiler and integrated development environment. It is free of charge and can be downloaded from any website. The first release of Turbo C++ was released in May 1990 version 1.0, running on MS-DOS computers. For the C++ programming language, Turbo C++ is an integrated
4 min read
How to Install Visual C++ on Linux? Visual C++ is Software made by Microsoft Corporation. It is used to build desktop applications using the C and C++ languages. It was initially released in February 1993. In this article, we are going to learn how we can install Visual C++ in our Linux System. Installing Visual C++ on Linux: Step 1:
2 min read
Hello World Program in Perl Perl programming language is exclusively designed for text processing purposes. Its abbreviation denotes Practical Extraction and Report Language. It is compatible on various platforms, such as Windows, Mac OS, and almost all versions of UNIX. Hello World! program in every programming language gives
3 min read