How to Install Clang on Ubuntu 22.04

Clang is a front-end open-source compiler for the C, C++, and Objective-C programming languages. It is part of the LLVM project, which is a collection of modular and reusable compiler and tool-chain technologies. Clang is used to translate human-readable code into machine-executable binary files.

In today’s tutorial, we will learn the procedure for installing Clang on Ubuntu 22.04.

How to Install Clang on Ubuntu 22.04 Using apt?

In this section, we will provide you with a procedure for installing Clang on Ubuntu 22.04 using apt.

Step 1: Update the Packages

Hit “CTRL+ALT+T” for opening up the terminal:

sudo apt update

Step 2: Install Clang

Execute the command to install Clang:

sudo apt install clang -y

Clang has been installed successfully.

How to Verify the Installation of Clang on Ubuntu 22.04?

Once Clang is installed, run the mentioned command to confirm its installation:

clang --version

How to Use Clang on Ubuntu 22.04?

After the successful installation of the Clang, the next step is to learn how to run programs using it:

Step 1: Create a C Source Code file

Using your preferred text editor, create and open a file with an extension “.c”:

nano myprogram.c

Step 2: Edit the File

Write a program in the opened file. In our case, we have written this short program:

#include <stdio.h>

int main() {
printf("Hello, LinuxGenie User!\n");
return 0;

Step 3: Compile the C Program

Next, run the command below to compile the program:

clang myprogram.c -o myprogram

Note: “-o” specifies the output file name.

Step 4: Run the file

At last, write down this command in the terminal to run the program:


How to Uninstall/Remove Clang on Ubuntu 22.04?

If you no longer want to keep Clang on your Ubuntu 22.04, you uninstall it by following the method mentioned below.

Step 1: Uninstall Clang

As the first step, utilize the below command for uninstalling Clang:

sudo apt remove clang -y

Step 2: Remove Extra Files

By executing the command mentioned below, you can get the additional Clang files removed from your Ubuntu 22.04:

sudo apt autoremove -y

That was all from the guide.


To install Clang on Ubuntu 22.04, launch the terminal first. After that, run the “sudo apt update” command for updating the packages. Then, install Clang using the “sudo apt install clang -y” command. Verify its installation by executing the “clang –version” command. Moreover, we have briefly described the procedure for executing a C program using Clang on Ubuntu 22.04.

Print Friendly, PDF & Email