Using this guide you can install Clang 18.

In brief, there are 2 steps:

  1. Download and run the automatic installation script using the terminal

    wget -qO- https://apt.llvm.org/llvm.sh | bash -s -- 18
    

    During the process, it might ask to hit Enter to confirm adding the apt repository. Then, you may just wait until the process done.

  2. Verify by calling

    clang-18 --version
    

    and/or locate clang-18 to verify.

Answer from graham on askubuntu.com
🌐
UbuntuHandbook
ubuntuhandbook.org › home › howtos › install clang 21, 22, or 23 in ubuntu 26.04 | 24.04 | 22.04
Install Clang 21, 22, or 23 in Ubuntu 26.04 | 24.04 | 22.04 | UbuntuHandbook
This simple tutorial shows how to install the most recent Clang compiler 23, 22, or 21 in current Ubuntu 26.04, Ubuntu 24.04, Ubuntu 22.04, and Ubuntu 20.04 LTS and correct the deprecated repository settings.
🌐
GeeksforGeeks
geeksforgeeks.org › linux-unix › how-to-install-clang-on-ubuntu-linux
Installation of Clang on Ubuntu - GeeksforGeeks
February 14, 2026 - This can be done by using the apt manager on the system. So we need to execute the below update command to update all the repositories to their latest version. ... Now, by using the APT manager, install the Clang Tool on Ubuntu Linux.
🌐
LLVM
apt.llvm.org
LLVM Debian/Ubuntu packages
apt-get install clang-21 lldb-21 lld-21 To install all key packages:
Top answer
1 of 11
75

With Ubuntu 16.04, simply do:

sudo apt install clang-format
2 of 11
38

Nowadays, you can directly use apt install clang-format in Debian/Ubuntu to install clang-format. However, the clang-format provided by Debian/Ubuntu is quite old. For example, the latest version of clang-format from Ubuntu 18.04 is v7 but the latest stable version is already reached v12. You can install the latest version of clang-format by following the steps below:

Step 1: Run wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add -

Step 2: Append the following content at the end of /etc/apt/sources.list based on your operating system:

  • Buster (Debian 10):

    deb http://apt.llvm.org/buster/ llvm-toolchain-buster main
    deb-src http://apt.llvm.org/buster/ llvm-toolchain-buster main
    # 11 
    deb http://apt.llvm.org/buster/ llvm-toolchain-buster-11 main
    deb-src http://apt.llvm.org/buster/ llvm-toolchain-buster-11 main
    # 12 
    deb http://apt.llvm.org/buster/ llvm-toolchain-buster-12 main
    deb-src http://apt.llvm.org/buster/ llvm-toolchain-buster-12 main
    
  • Bullseye (Debian 11):

    deb http://apt.llvm.org/bullseye/ llvm-toolchain-bullseye main
    deb-src http://apt.llvm.org/bullseye/ llvm-toolchain-bullseye main
    # 11 
    deb http://apt.llvm.org/bullseye/ llvm-toolchain-bullseye-11 main
    deb-src http://apt.llvm.org/bullseye/ llvm-toolchain-bullseye-11 main
    # 12 
    deb http://apt.llvm.org/bullseye/ llvm-toolchain-bullseye-12 main
    deb-src http://apt.llvm.org/bullseye/ llvm-toolchain-bullseye-12 main
    
  • Xenial (Ubuntu 16.04):

    deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial main
    deb-src http://apt.llvm.org/xenial/ llvm-toolchain-xenial main
    # 11
    deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-11 main
    deb-src http://apt.llvm.org/xenial/ llvm-toolchain-xenial-11 main
    # 12
    deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-12 main
    deb-src http://apt.llvm.org/xenial/ llvm-toolchain-xenial-12 main
    
  • Bionic (Ubuntu 18.04):

    deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic main
    deb-src http://apt.llvm.org/bionic/ llvm-toolchain-bionic main
    # 11
    deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-11 main
    deb-src http://apt.llvm.org/bionic/ llvm-toolchain-bionic-11 main
    # 12
    deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-12 main
    deb-src http://apt.llvm.org/bionic/ llvm-toolchain-bionic-12 main
    
  • Focal (Ubuntu 20.04)

    deb http://apt.llvm.org/focal/ llvm-toolchain-focal main
    deb-src http://apt.llvm.org/focal/ llvm-toolchain-focal main
    # 14
    deb http://apt.llvm.org/focal/ llvm-toolchain-focal-14 main
    deb-src http://apt.llvm.org/focal/ llvm-toolchain-focal-14 main
    # 15
    deb http://apt.llvm.org/focal/ llvm-toolchain-focal-15 main
    deb-src http://apt.llvm.org/focal/ llvm-toolchain-focal-15 main
    
  • Jammy (Ubuntu 22.04)

    deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy main
    deb-src http://apt.llvm.org/jammy/ llvm-toolchain-jammy main
    # 14
    deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-14 main
    deb-src http://apt.llvm.org/jammy/ llvm-toolchain-jammy-14 main
    # 15
    deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-15 main
    deb-src http://apt.llvm.org/jammy/ llvm-toolchain-jammy-15 main
    

You can check https://apt.llvm.org/ if your operating system is not on this list.

Step 3: Run sudo apt update

Step 4: Run apt search clang-format and check all available versions:

$ sudo apt search clang-format
Sorting... Done
Full Text Search... Done
arcanist-clang-format-linter/stable 0.git20161021-2 all
  clang-format linter for Arcanist

clang-format/unknown 1:13.0-53~20210202214848.38 amd64
  Tool to format C/C++/Obj-C code

clang-format-11/unknown 1:11.1.0~++20210203115409+1fdec59bffc1-1~exp1~20210203230038.161 amd64
  Tool to format C/C++/Obj-C code

clang-format-12/unknown 1:12.0.0~++20210312110334+ca14f0282fce-1~exp1~20210312221110.59 amd64
  Tool to format C/C++/Obj-C code

clang-format-13/unknown 1:13~++20210315063844+b868a3edad9d-1~exp1~20210315174553.2286 amd64
  Tool to format C/C++/Obj-C code

clang-format-6.0/stable 1:6.0.1-10 amd64
  Tool to format C/C++/Obj-C code

clang-format-7/stable 1:7.0.1-8+deb10u2 amd64
  Tool to format C/C++/Obj-C code

Step 5: Use apt install to install the clang-format you want. Then you can use --version to check the installed clang-format. You can install multiple versions of clang-format in a same environment.

$ sudo apt install -y clang-format-12
$ clang-format-12 --version
Ubuntu clang-format version 12.0.0-++20210312110334+ca14f0282fce-1~exp1~20210312221110.59

$ sudo apt install -y clang-format
$ clang-format --version
Ubuntu clang-format version 13.0.0-++20210315063844+b868a3edad9d-1~exp1~20210315174553.2286
🌐
Ubuntu
documentation.ubuntu.com › ubuntu-for-developers › reference › availability › llvm
Available LLVM/Clang versions - Ubuntu for Developers
1 week ago - This page lists LLVM/Clang versions available in Ubuntu releases. Ubuntu (deb) packages:,,, Ubuntu version, available LLVM/Clang versions, llvm-defaults,,, 26.10 (Stonking Stingray)¹, 17, 18, 19, 2...
🌐
bodHOST
bodhost.com › general discussion › how to install clang on ubuntu 20.04 and 22.04
How to Install Clang on Ubuntu 20.04 and 22.04
February 26, 2026 - Clang serves as a compiler front ... To begin, ensure you have the latest software versions by updating the package index with the command- sudo apt update...
🌐
TecAdmin
tecadmin.net › how-to-install-clang-on-ubuntu
How to Install Clang on Ubuntu 22.04 & 20.04 – TecAdmin
April 26, 2025 - It’s also a good idea to update ... get the latest version of Clang available in the Ubuntu repositories. Open a terminal (Ctrl+Alt+T). Run the command to update package lists and upgrade the system: ... Ubuntu’s official package repositories include Clang. To install the latest ...
Find elsewhere
🌐
GitHub
gist.github.com › Ouroboros › 0beec448f61c9926023633ca532184dc
How to install latest clang (5.0) on Ubuntu 16.04 (xenial) / WSL · GitHub
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - sudo apt-add-repository "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-5.0 main" sudo apt-get update sudo apt-get install -y clang-5.0 lld-5.0
🌐
GeeksforGeeks
geeksforgeeks.org › how-to-install-clang-on-ubuntu-linux
How to Install Clang on Ubuntu Linux? - GeeksforGeeks
September 20, 2024 - This can be done by using the apt manager on the system. So we need to execute the below update command to update all the repositories to their latest version. ... Now, by using the APT manager, install the Clang Tool on Ubuntu Linux.
🌐
LinuxShout
linux.how2shout.com › home › how to install clang on ubuntu linux
How to Install Clang on Ubuntu Linux - LinuxShout - H2S Media
July 31, 2023 - Well, the previous step’s command will provide you with version 14 of Clang which was available through the Ubuntu 22.04 repo by default while performing this tutorial. However, those who want the latest version or even some older one can run the given commands:
🌐
Howtoinstall.me
howtoinstall.me › ubuntu › 18-04 › clang
How to Install clang in Ubuntu 18.04
Ubuntu · 18.04 · clang · Install clang by entering the following commands in the terminal: sudo apt update sudo apt install clang · Description: C, C++ and Objective-C compiler (LLVM based) Clang project is a C, C++, Objective C and Objective C++ front-end for the LLVM compiler.
🌐
eUKhost
eukhost.com › home › how to install clang on ubuntu 22.04 & 20.04
How to install Clang on Ubuntu 22.04 & 20.04 - eukhost
December 20, 2024 - Learn how to install Clang on Ubuntu 22.04 and 20.04 with easy steps. Follow our guide for smooth setup and efficient development.
🌐
Lindevs
lindevs.com › install-clang-on-ubuntu
Install Clang 19 on Ubuntu 24.04 | Lindevs
June 1, 2025 - Clang is a compiler for the C, C++, Objective-C, and Objective-C++ programming languages. It is part of the LLVM project, which provides a collection of modular and reusable compiler and toolchain technologies. This tutorial explains how to install Clang 19 on Ubuntu 24.04.
🌐
Clang
clang.llvm.org › get_started.html
Getting Started: Building and Running Clang - LLVM
git clone --depth=1 https://github.com/llvm/llvm-project.git (using this only the latest version of llvm can be built) For normal users looking to just compile, this command works fine. But if someone later becomes a contributor, since they can't push code from a shallow clone, it needs to ...
🌐
Host
host.co.in › kb › how-to-install-clang-on-ubuntu-20-04-and-22-04
How to Install Clang on Ubuntu 20.04 and 22.04
Clang is a powerful compiler front ... will walk you through the process of installing Clang on Ubuntu 20.04 and 22.04 using the apt package manager. ... Before installing Clang, ensure your system has the latest package information....
🌐
AddictiveTips
addictivetips.com › home › how to install clang on ubuntu
How to Install Clang Libraries on Ubuntu: A Step-by-Step Guide
August 28, 2024 - Or, search for “Terminal” in the app menu. Once it is open, use the apt install command and the –install-suggests command-line switch to get Clang 11 set up, along with Ubuntu suggested packages.