Skip to content

How to Install VS Code on Ubuntu (24.04, 22.04 and 20.04)

Updated: May 2026 | Three methods covered | Works on all active Ubuntu LTS releases

VS Code is the most popular code editor in the world for good reason — it’s fast, extensible, and works beautifully on Linux. If you want to know how to install VS Code on Ubuntu, you have three options: Snap, APT repository, or a .deb package. Each has trade-offs worth understanding before you pick one.

This guide covers how to install VS Code on Ubuntu 24.04 LTS (Noble Numbat), Ubuntu 22.04 LTS (Jammy Jellyfish), and Ubuntu 20.04 LTS (Focal Fossa) — all three methods, step by step, with verification commands and troubleshooting tips at the end.


Which installation method should you choose?

MethodBest forAuto-updatesNotes
SnapBeginners, fastest setupYesSlightly slower launch time
APT repositoryMost users, recommendedYesIntegrates with system package manager
.deb packageOne-time manual installNoManual updates required

For most users, the APT repository method is the best choice — it integrates cleanly with Ubuntu’s package manager, updates automatically with apt upgrade, and doesn’t have the sandboxing overhead of Snap. The Snap method is perfectly fine if you prefer simplicity. The .deb method is useful when you need a quick install without touching your package sources.


Method 1 — How to install VS Code on Ubuntu using Snap (fastest)

The Snap method is the quickest way to install VS Code on Ubuntu. If you’re running Ubuntu 20.04 LTS or later, Snap is already installed and ready to go — you don’t need to do anything before running the install command.

Step 1: Install VS Code via Snap

bash

sudo snap install code --classic

The --classic flag is required. It allows VS Code to access files outside its sandbox — without it, VS Code can’t open projects in your home directory or other locations outside the Snap confinement.

Step 2: Verify the installation

bash

code --version

You should see the VS Code version number, commit hash, and architecture. If this returns a version number, VS Code is installed and ready.

Step 3: Launch VS Code

bash

code

Or search for “Visual Studio Code” in your application launcher.

To update VS Code installed via Snap:

Snap packages update automatically in the background. To force an immediate update:

bash

sudo snap refresh code

To uninstall VS Code installed via Snap:

bash

sudo snap remove code

Method 2 — How to install VS Code on Ubuntu using the APT repository (recommended)

This is the recommended method for most users. It adds Microsoft’s official VS Code repository to your system so that VS Code updates automatically whenever you run sudo apt upgrade.

Step 1: Update your package index and install dependencies

bash

sudo apt update
sudo apt install -y wget gpg apt-transport-https

Step 2: Import Microsoft’s GPG signing key

bash

wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg
sudo install -D -o root -g root -m 644 packages.microsoft.gpg /etc/apt/keyrings/packages.microsoft.gpg
rm packages.microsoft.gpg

This downloads and installs the GPG key that verifies packages from Microsoft’s repository are authentic and untampered.

Step 3: Add the VS Code repository

bash

echo "deb [arch=amd64,arm64,armhf signed-by=/etc/apt/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" | sudo tee /etc/apt/sources.list.d/vscode.list

Step 4: Update the package index and install VS Code

bash

sudo apt update
sudo apt install code

Step 5: Verify the installation

bash

code --version

To update VS Code installed via APT:

VS Code updates automatically with your system updates. To update manually:

bash

sudo apt update && sudo apt upgrade code

To uninstall VS Code installed via APT:

bash

sudo apt remove code

To also remove the repository:

bash

sudo rm /etc/apt/sources.list.d/vscode.list
sudo rm /etc/apt/keyrings/packages.microsoft.gpg

Method 3 — How to install VS Code on Ubuntu using a .deb package (manual)

The easiest way to install VS Code for Debian/Ubuntu based distributions is to download and install the .deb package directly, either through the graphical software center or through the command line. This method doesn’t add a repository to your system — useful if you want a clean one-time install without modifying your package sources. LinuxLap

Step 1: Download the latest .deb package

bash

wget -O vscode.deb "https://code.visualstudio.com/sha/download?build=stable&os=linux-deb-x64"

Or download it manually from code.visualstudio.com/download and select the .deb option under Linux.

Step 2: Install the package

bash

sudo apt install ./vscode.deb

Step 3: Clean up the downloaded file

bash

rm vscode.deb

Step 4: Verify the installation

bash

code --version

Note on updates with the .deb method:

When you install the .deb package, it prompts to install the apt repository and signing key to enable auto-updating using the system’s package manager. If you accept this during installation, future updates will be handled automatically via apt upgrade — effectively giving you the same behaviour as Method 2. If you decline, you will need to repeat the .deb download process to update manually. LinuxLap


How to install VS Code on Ubuntu 20.04 specifically

All three methods above work identically on Ubuntu 20.04 LTS. There are no version-specific differences for 20.04. The only thing worth noting is that Ubuntu 20.04 standard support ended in April 2025 — it is now on Extended Security Maintenance (ESM). If you are still running 20.04, consider upgrading to 22.04 or 24.04 at your next opportunity.


Launch VS Code from the terminal

Once installed by any method, launch VS Code from the terminal with:

bash

code

To open a specific file:

bash

code filename.py

To open the current directory as a workspace:

bash

code .

The code . command is one of the most useful habits to build — it opens the entire current directory as a VS Code project instantly.


Set VS Code as the default editor (optional)

Debian-based distributions allow setting a default editor using the alternatives system. To set VS Code as the default text editor: LinuxLap

bash

sudo update-alternatives --set editor /usr/bin/code

If VS Code was installed via Snap, use this command instead:

bash

sudo update-alternatives --set editor /snap/bin/code

Troubleshooting common issues

code: command not found after Snap install

Log out and back in, or restart your terminal session. Snap’s PATH entries sometimes don’t take effect until the session is refreshed:

bash

source ~/.bashrc

If that doesn’t work, restart your system:

bash

sudo reboot

GPG key error during APT installation

If you see GPG error: https://packages.microsoft.com during apt update, re-run the GPG key import step:

bash

wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg
sudo install -D -o root -g root -m 644 packages.microsoft.gpg /etc/apt/keyrings/packages.microsoft.gpg
sudo apt update

dpkg: dependency problems during .deb install

If sudo apt install ./vscode.deb fails with dependency errors, fix them with:

bash

sudo apt install -f

VS Code opens but extensions won’t install

This is occasionally caused by Snap’s sandboxing. If you installed via Snap and are having persistent extension issues, consider reinstalling via the APT method instead:

bash

sudo snap remove code
# Then follow Method 2 above

ARM64 users (Raspberry Pi, Apple Silicon VM)

Replace amd64 with arm64 in the APT repository step:

bash

echo "deb [arch=arm64 signed-by=/etc/apt/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" | sudo tee /etc/apt/sources.list.d/vscode.list

Recommended extensions to install after VS Code

Once VS Code is running, these are the most useful extensions to install first depending on your workflow:

For general development:

  • GitLens — supercharges the built-in Git integration with blame annotations and history
  • Prettier — automatic code formatting for JavaScript, TypeScript, CSS, HTML and more
  • Path Intellisense — autocompletes file paths as you type them

For Python:

  • Python (Microsoft) — linting, debugging, Jupyter notebook support
  • Pylance — fast, feature-rich language server for Python

For web development:

  • ESLint — identifies and fixes JavaScript/TypeScript problems
  • Live Server — launches a local development server with live reload

For Linux/shell work:

  • ShellCheck — lints your bash and shell scripts for common errors
  • Remote – SSH — opens any remote server as a VS Code workspace over SSH

Install any extension directly from the terminal:

bash

code --install-extension ms-python.python
code --install-extension eamodio.gitlens

Summary — how to install VS Code on Ubuntu in one command

If you just want the fastest path to a working VS Code install on Ubuntu 20.04, 22.04, or 24.04:

Snap (one command, done):

bash

sudo snap install code --classic

APT (recommended for most users):

bash

wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg && sudo install -D -o root -g root -m 644 packages.microsoft.gpg /etc/apt/keyrings/packages.microsoft.gpg && echo "deb [arch=amd64,arm64,armhf signed-by=/etc/apt/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" | sudo tee /etc/apt/sources.list.d/vscode.list && sudo apt update && sudo apt install code

Both methods result in a fully working, automatically updated VS Code installation. The choice comes down to whether you prefer Snap’s simplicity or APT’s tighter system integration.

linux in IoT

The Role of Linux in IoT: Powering the Connected World

How to Install VS Code on Ubuntu (24.04, 22.04 and 20.04)

How to Install VS Code on Ubuntu (24.04, 22.04 and 20.04)

Updated: May 2026 | Three methods covered | Works on all active Ubuntu LTS releases VS Code is the m…

best Linux Distro for Old Laptops

Best Linux Distro for Old Laptops in 2026 (Your Windows 10 Replacement Guide)

Updated: May 2026 | Tested on hardware with 1GB–8GB RAM | Covers laptops from 2010–2020 Windows 10 s…

How to Fix Copy Fail

How to Fix Copy Fail (CVE-2026-31431) on Ubuntu, Debian, Fedora, RHEL, AlmaLinux and Arch

How to Fix Copy Fail – Updated: May 5, 2026 Covers all major distributions with verified patch…

Copy Fail (CVE-2026-31431): The Worst Linux Security Vulnerability in Years

Copy Fail (CVE-2026-31431): The Worst Linux Security Vulnerability in Years

Published: May 2026 | Affects every major Linux distribution built since 2017 A critical Linux kerne…

Best Linux Distros for Privacy and Security in 2026

Best Linux Distros for Privacy and Security in 2026

Privacy in 2026 is not a nice-to-have — it’s a necessity. Windows 11 phones home constantly. m…

Fedora Linux 44 official release artwork

Fedora Linux 44 Is Here: Everything You Need to Know About this Latest Release

Fedora Linux 44 has officially landed, and it’s one of the most feature-packed releases the co…

DIY Solar Planning

Can AI Actually Lower Your Electric Bill? A Practical Guide to DIY Solar Planning