Debian already packages Clang in its default repositories, but it is not installed by default and the compiler branch changes sharply between Debian 13, 12, and 11. That matters when you need newer LLVM diagnostics, sanitizers, or the same toolchain branch your CI pipeline uses. If you need to install Clang on Debian, the distro package covers the standard compiler path and the LLVM packaging repo adds a newer branch without replacing Debian’s own clang command.
Both methods here work on Debian 13 (trixie), Debian 12 (bookworm), and Debian 11 (bullseye). Debian’s default APT sources provide the unversioned clang command, while apt.llvm.org installs a versioned binary such as clang-20 so it can live beside the distro toolchain.
Install Clang on Debian
Start by refreshing APT metadata before you choose a Clang package.
sudo apt update
These commands use
sudofor package management and writing APT configuration files. If your account does not have sudo access yet, run the commands as root or follow the guide on how to add a user to sudoers on Debian.
Debian already includes Clang in its default repositories, so most systems do not need a third-party source. The LLVM repository still helps when you want a newer stable branch without replacing Debian’s own clang package.
| Method | Channel | Version | Updates | Best For |
|---|---|---|---|---|
| Debian APT | Debian packages | Debian 13: 19.1.x; Debian 12: 14.0.x; Debian 11: 11.0.x | APT-managed | Most users, build hosts, and stable systems |
| LLVM APT repository | apt.llvm.org | Clang 20.x via clang-20 | APT-managed | Newer LLVM branch without replacing Debian’s clang command |
For most Debian systems, the default APT package is the better fit because it installs the normal clang launcher and follows the toolchain branch packaged for your release. From Debian’s default APT sources, Debian 13 installs Clang 19.1.x, Debian 12 installs Clang 14.0.x, and Debian 11 installs Clang 11.0.x. The LLVM repository adds Clang 20.x as clang-20 across all three releases.
Install Clang from Debian APT on Debian
Use Debian’s own package when you want the compiler branch maintained for your release and the standard /usr/bin/clang command.
sudo apt install clang
Check the installed compiler version next.
clang --version
Debian 13 returns:
Debian clang version 19.1.7 (3+b1)
On Debian 12, the same check returns Debian clang version 14.0.6. On Debian 11, it returns Debian clang version 11.0.1-2. This method installs the unversioned compiler at /usr/bin/clang, which is the path most Debian build instructions expect.
Install Clang 20 from apt.llvm.org on Debian
Use the LLVM repository when you need a newer Clang branch than Debian ships but still want APT-managed packages. These commands target the versioned Clang 20 branch because apt.llvm.org publishes it for Debian 13, 12, and 11. Do not substitute a different branch unless the package policy check shows a valid candidate for your release and architecture.
The official llvm.sh helper is useful for broad LLVM installs, but it installs extra packages such as lld, lldb, and clangd. The manual DEB822 setup in this section keeps this install focused on the Clang compiler package and makes cleanup easier to audit.
Install the prerequisites first. Debian desktops often already have ca-certificates, but server and minimal images are the ones most likely to need the full set.
sudo apt install ca-certificates curl gpg
The repository setup uses the curl command in Linux with -fsSL so the download follows redirects, stays quiet unless an error occurs, and fails fast on HTTP problems.
Download the current LLVM signing key, convert it into a binary keyring, and install that keyring into APT’s shared keyring directory.
curl -fsSLo llvm-snapshot.gpg.key https://apt.llvm.org/llvm-snapshot.gpg.key
gpg --dearmor --yes -o apt-llvm-org.gpg llvm-snapshot.gpg.key
sudo install -m 0644 apt-llvm-org.gpg /usr/share/keyrings/apt-llvm-org.gpg
rm -f llvm-snapshot.gpg.key apt-llvm-org.gpg
The local download avoids running the network fetch as root. The gpg --dearmor --yes step converts the ASCII-armored key into a binary keyring that APT can read directly, and --yes keeps the command rerunnable if you refresh the key later.
Write the LLVM repository source file next.
. /etc/os-release
arch="$(dpkg --print-architecture)"
printf '%s\n' \
"Types: deb" \
"URIs: https://apt.llvm.org/${VERSION_CODENAME}/" \
"Suites: llvm-toolchain-${VERSION_CODENAME}-20" \
"Components: main" \
"Architectures: ${arch}" \
"Signed-By: /usr/share/keyrings/apt-llvm-org.gpg" | sudo tee /etc/apt/sources.list.d/apt-llvm-org.sources > /dev/null
The . /etc/os-release line loads Debian’s codename from the local system, so you do not need lsb_release. The architecture line keeps APT on the local Debian architecture, and tee writes the root-owned .sources file because a plain > redirection would not inherit sudo.
Refresh APT so Debian can read the new LLVM source.
sudo apt update
APT picks up the new LLVM source:
Get:4 https://apt.llvm.org/trixie llvm-toolchain-trixie-20 InRelease [6,834 B] Get:5 https://apt.llvm.org/trixie llvm-toolchain-trixie-20/main amd64 Packages [21.9 kB] Reading package lists...
Confirm that APT can see the versioned compiler package before you install it.
apt-cache policy clang-20
clang-20:
Installed: (none)
Candidate: 1:20.1.8~++20250809043815+87f0227cb601-1~exp1~20250809163919.3
Version table:
1:20.1.8~++20250809043815+87f0227cb601-1~exp1~20250809163919.3 500
500 https://apt.llvm.org/trixie llvm-toolchain-trixie-20/main amd64 Packages
On Debian 12 and Debian 11, the repository line switches to bookworm or bullseye, but the package name stays clang-20.
If the candidate shows (none), stop before installing. Recheck the branch number, Debian codename, and local architecture in the source file because apt.llvm.org does not publish every branch for every release and architecture combination.
The same source also exposes companion packages such as clang-tools-20 and clangd-20. Keep those separate from the compiler install unless you need matching command-line tools or editor language-server support.
Install the newer Clang branch next.
sudo apt install clang-20
APT installs clang-20 with the LLVM runtime libraries and, on a normal APT configuration, recommended tools such as clang-tools-20. Systems configured with --no-install-recommends may install a smaller package set, so the next compiler check is the reliable success test.
Verify the versioned compiler binary after installation.
clang-20 --version && command -v clang-20
Debian clang version 20.1.8 (++20250809043815+87f0227cb601-1~exp1~20250809163919.3) /usr/bin/clang-20
The LLVM repository installs versioned binaries like
clang-20. It does not replace Debian’s unversioned/usr/bin/clangcommand automatically.
Compile a Test Program with Clang on Debian
A quick compile test confirms either install method works. Use clang for the Debian package or clang-20 if you added apt.llvm.org.
Compile a Test Program with Debian’s Clang on Debian
Create a tiny C program and build it with the unversioned Debian compiler.
cat <<'EOF' > hello-clang.c
#include <stdio.h>
int main(void) {
puts("Clang works on Debian.");
return 0;
}
EOF
clang hello-clang.c -o hello-clang
./hello-clang
Clang works on Debian.
If you are moving from a single-file test to a larger build, install CMake on Debian for generator-based projects and install Git on Debian for source checkouts and branch work.
Compile a Test Program with Clang 20 from apt.llvm.org on Debian
If you installed the LLVM repository package, rebuild the same source file with the versioned binary.
clang-20 hello-clang.c -o hello-clang-20
./hello-clang-20
Clang works on Debian.
Update or Remove Clang on Debian
APT handles updates and removal cleanly for both methods, but the commands differ because Debian ships an unversioned metapackage while the LLVM repository installs a release-specific binary.
Update Debian APT Clang on Debian
Debian tracks a different Clang branch on each supported release, so use the update command that matches your release.
On Debian 13, update the Trixie packages with:
sudo apt update && sudo apt install --only-upgrade clang clang-19
On Debian 12, update the Bookworm packages with:
sudo apt update && sudo apt install --only-upgrade clang clang-14
On Debian 11, update the Bullseye packages with:
sudo apt update && sudo apt install --only-upgrade clang clang-11
Update Clang 20 from apt.llvm.org on Debian
If you installed the LLVM repository build, update the versioned compiler package and the matching tools package that APT normally installs with it.
sudo apt update && sudo apt install --only-upgrade clang-20 clang-tools-20
If you separately installed clangd-20 for editor integration, include it in the same update command.
Remove Debian APT Clang on Debian
Debian’s clang package is only a metapackage. Removing it by itself leaves the real compiler package behind, so remove both the metapackage and the matching release-specific package.
On Debian 13, remove the Trixie packages with:
sudo apt remove clang clang-19
On Debian 12, remove the Bookworm packages with:
sudo apt remove clang clang-14
On Debian 11, remove the Bullseye packages with:
sudo apt remove clang clang-11
If APT lists now-unused support libraries, multilib packages, or other stale packages afterward, review them with sudo apt autoremove before you confirm that cleanup.
sudo apt autoremove
After removal, confirm both the metapackage and the release-specific compiler package are gone.
On Debian 13, the verification check is:
for pkg in clang clang-19; do
dpkg-query -W -f='${db:Status-Abbrev}\n' "$pkg" 2>/dev/null | grep -q '^ii' && echo "$pkg is still installed" || echo "$pkg is not installed"
done
clang is not installed clang-19 is not installed
On Debian 12, run the same check with the Bookworm compiler package name:
for pkg in clang clang-14; do
dpkg-query -W -f='${db:Status-Abbrev}\n' "$pkg" 2>/dev/null | grep -q '^ii' && echo "$pkg is still installed" || echo "$pkg is not installed"
done
clang is not installed clang-14 is not installed
On Debian 11, use the Bullseye package name instead:
for pkg in clang clang-11; do
dpkg-query -W -f='${db:Status-Abbrev}\n' "$pkg" 2>/dev/null | grep -q '^ii' && echo "$pkg is still installed" || echo "$pkg is not installed"
done
clang is not installed clang-11 is not installed
Remove Clang 20 from apt.llvm.org on Debian
Remove the versioned LLVM compiler and its tools package first.
sudo apt remove clang-20 clang-tools-20
If APT lists additional auto-installed LLVM support packages afterward, review the list before confirming autoremove.
sudo apt autoremove
Remove the repository source and refresh APT metadata. The keyring is removed only when no remaining APT source references it.
sudo rm -f /etc/apt/sources.list.d/apt-llvm-org.sources
if [ -f /etc/apt/sources.list ]; then
key_refs=$(sudo grep -R -l --fixed-strings '/usr/share/keyrings/apt-llvm-org.gpg' /etc/apt/sources.list /etc/apt/sources.list.d 2>/dev/null || true)
else
key_refs=$(sudo grep -R -l --fixed-strings '/usr/share/keyrings/apt-llvm-org.gpg' /etc/apt/sources.list.d 2>/dev/null || true)
fi
if [ -z "$key_refs" ]; then
sudo rm -f /usr/share/keyrings/apt-llvm-org.gpg
fi
sudo apt update
Because clang-20 disappears from APT once you remove the LLVM source, check the installed package state instead of using apt-cache policy to prove the package is gone.
for pkg in clang-20 clang-tools-20; do
dpkg-query -W -f='${db:Status-Abbrev}\n' "$pkg" 2>/dev/null | grep -q '^ii' && echo "$pkg is still installed" || echo "$pkg is not installed"
done
clang-20 is not installed clang-tools-20 is not installed
Troubleshoot Clang on Debian
The most common issue after the LLVM repository install is a missing unversioned clang command even though the package is present.
Fix Clang Command Errors After Installing Clang 20 on Debian
If you try to run clang after installing only the LLVM repository package, the shell can still report a missing command.
clang --version
bash: clang: command not found
The cause is the package name and binary name mismatch. apt.llvm.org installs the versioned compiler as clang-20, not as the unversioned Debian launcher.
Verify the versioned binary directly.
clang-20 --version && command -v clang-20
Debian clang version 20.1.8 (++20250809043815+87f0227cb601-1~exp1~20250809163919.3) /usr/bin/clang-20
If you want the unversioned clang command for existing Debian build instructions, install Debian’s own clang package instead of relying on clang-20 alone.
Conclusion
Clang is installed on Debian through either the distro’s clang package or the separate clang-20 toolchain from apt.llvm.org. Keep Debian’s package when you want the unversioned compiler command and the least maintenance, or use the LLVM repo for a newer branch, then install CMake on Debian for larger builds and install Git on Debian to track your source tree.


Formatting tips for your comment
You can use basic HTML to format your comment. Useful tags currently allowed in published comments:
<code>command</code>command<strong>bold</strong><em>italic</em><blockquote>quote</blockquote>