How to Install Visual Studio Code on Ubuntu 26.04, 24.04 and 22.04

Last updated Wednesday, April 29, 2026 10:54 am Joshua James 8 min read

Ubuntu developers often choose Visual Studio Code when they want IntelliSense, debugging, Git integration, terminal access, and the extension marketplace in one desktop editor. To install Visual Studio Code on Ubuntu, use Microsoft’s APT repository for the most direct upstream package, or choose Snap or Flatpak when their update model fits your system better. The same installation choices apply to Ubuntu 26.04 LTS, 24.04 LTS, and 22.04 LTS.

Install Visual Studio Code on Ubuntu

Ubuntu does not include Microsoft’s Visual Studio Code package in its default repositories, and Microsoft does not publish a Launchpad PPA for VS Code. The usual Ubuntu choices are Microsoft’s APT repository, the official Snap package, or the Flathub package.

MethodSourceBuildsUpdatesBest For
Microsoft APT repositoryMicrosoft Linux setup docsStable and InsidersManual through APTMost users who want Microsoft’s Ubuntu package and normal APT control
SnapSnapcraftStable and InsidersAutomatic Snap refreshesUsers who want the official Snap package and hands-off updates
FlatpakFlathubStable onlyManual with flatpak updateUsers who prefer Flatpak sandboxing after setting up Flathub

For most Ubuntu systems, start with the Microsoft APT repository. It provides the vendor-published code and code-insiders packages, keeps updates in APT, and creates the standard code terminal launcher. Snap is also published by the Visual Studio Code Snapcraft account and uses classic confinement. Flatpak uses the com.visualstudio.code app ID on Flathub, but it is a separate Flatpak packaging path rather than the Microsoft APT package.

These instructions target Ubuntu 26.04 LTS, 24.04 LTS, and 22.04 LTS. The Microsoft repository uses the codename-neutral stable suite, so the APT setup does not change between those supported LTS releases.

If you searched for a VS Code download instead of repository commands, Microsoft still provides an official 64-bit Debian/Ubuntu .deb download. The Microsoft repository method is better for maintained systems because future VS Code updates remain visible to APT instead of depending on repeated manual downloads.

Install VS Code with Microsoft APT Repository

Refresh Ubuntu Packages

Start by refreshing Ubuntu’s package index so APT has current metadata before you add the Microsoft repository:

sudo apt update

These commands use sudo for system-wide package changes. If your account cannot run administrative commands, follow the guide to add a user to sudoers on Ubuntu before continuing.

Install Repository Prerequisites

Install curl for HTTPS downloads and gpg for converting Microsoft’s signing key into the binary keyring format APT expects. The -y flag accepts the package prompt automatically:

sudo apt install curl gpg -y

Import Microsoft Signing Key

Download Microsoft’s repository signing key, convert it from ASCII armor to a binary keyring, and store it under /usr/share/keyrings/:

curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | sudo gpg --dearmor --yes -o /usr/share/keyrings/microsoft.gpg

The -fsSL flags make curl fail on HTTP errors, stay quiet unless an error occurs, and follow redirects. The --yes flag lets gpg replace an existing keyring during repeat runs without stopping for a prompt. For more examples of controlled downloads, see the curl command guide.

Add Microsoft VS Code APT Source

Create a DEB822 source file that points APT at Microsoft’s VS Code repository:

printf '%s\n' \
  'Types: deb' \
  'URIs: https://packages.microsoft.com/repos/code' \
  'Suites: stable' \
  'Components: main' \
  'Signed-By: /usr/share/keyrings/microsoft.gpg' \
  | sudo tee /etc/apt/sources.list.d/vscode.sources > /dev/null

The sudo tee command writes to a root-owned APT source file. A normal shell redirect such as > would run as your user account and fail on this system path.

Refresh APT and Check VS Code Candidates

Refresh APT again so it reads the Microsoft repository, then confirm both the Stable and Insiders packages are visible:

sudo apt update
apt-cache policy code code-insiders

Relevant output includes Microsoft repository candidates for both packages. Version numbers change as Microsoft publishes new builds:

code:
  Installed: (none)
  Candidate: 1.x.x-xxxxxxxxxx
  Version table:
     1.x.x-xxxxxxxxxx 500
        500 https://packages.microsoft.com/repos/code stable/main amd64 Packages

code-insiders:
  Installed: (none)
  Candidate: 1.x.x-xxxxxxxxxx
  Version table:
     1.x.x-xxxxxxxxxx 500
        500 https://packages.microsoft.com/repos/code stable/main amd64 Packages

Install VS Code Stable or Insiders

Install the Stable build for daily development:

sudo apt install code -y

Install the Insiders build only if you want early access to pre-release VS Code features:

sudo apt install code-insiders -y

You can keep Stable and Insiders installed at the same time. Stable uses the code command and the normal Code profile directories, while Insiders uses code-insiders and separate Insiders profile directories.

Verify VS Code APT Installation

Check the installed Stable build from the terminal:

code --version

Expected output uses the current VS Code version, commit, and architecture. If you installed Insiders, run code-insiders --version instead:

1.x.x
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
x64

Install VS Code with Snap

Confirm Snapd Is Available

Standard Ubuntu desktop installations normally include Snap. On minimal systems, flavors, or machines where Snap was removed, install snapd first:

sudo apt install snapd -y

Open a new terminal session if the snap command was not available before installing snapd.

Install the VS Code Snap Package

Install the Stable Snap package from the verified Visual Studio Code publisher on Snapcraft:

sudo snap install code --classic

Install the Insiders Snap package only if you want the preview channel:

sudo snap install code-insiders --classic

The --classic flag is required because VS Code needs broad access to project files, terminals, debuggers, and language tools outside a strict Snap sandbox.

Verify VS Code Snap Installation

Check that the Stable Snap package is installed and tracking the stable channel:

snap list code

Expected output:

Name  Version   Rev  Tracking       Publisher  Notes
code  xxxxxxxx  xxx  latest/stable  vscode**   classic

For Insiders, use snap list code-insiders instead.

Install VS Code with Flatpak

Flatpak is not pre-installed on Ubuntu. If your system does not already have Flatpak and Flathub configured, follow the guide to install Flatpak on Ubuntu before using this method.

Enable Flathub for VS Code

Add the Flathub remote at system scope so Ubuntu can install the VS Code Flatpak package:

sudo flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo

Confirm the remote exists before installing the application:

flatpak remotes --columns=name,options

Relevant output includes the system-scope Flathub remote:

flathub  system

Install the VS Code Flatpak Package

Install the Flathub package with the com.visualstudio.code app ID:

sudo flatpak install flathub com.visualstudio.code -y

This command installs the Flatpak at system scope. The -y flag accepts the install prompt automatically, and the command stays aligned with the system-scope Flathub remote.

Verify VS Code Flatpak Installation

Check the installed Flatpak metadata:

flatpak info com.visualstudio.code

Relevant output includes the app ID, stable branch, Flathub origin, and system installation scope:

Microsoft Corporation - Code editing. Redefined.

          ID: com.visualstudio.code
         Ref: app/com.visualstudio.code/x86_64/stable
        Arch: x86_64
      Branch: stable
     Version: 1.x.x
      Origin: flathub
Installation: system

Launch Visual Studio Code on Ubuntu

Launch VS Code from Terminal

Use the launch command that matches your installation method. For the APT Stable package, run:

code

For the APT Insiders package, run:

code-insiders

For the Stable Snap package, use Snap’s reliable launch form:

snap run code

For the Insiders Snap package, run:

snap run code-insiders

For the Flatpak package, run:

flatpak run com.visualstudio.code

Append a file or folder path to open a project directly, such as code ~/projects/myapp. Do not launch VS Code with sudo; open the editor as your normal user and run privileged commands only inside a terminal when needed.

Launch VS Code from Applications Menu

Ubuntu’s graphical launcher can also open VS Code after installation:

  1. Open Activities from the top-left corner of the desktop.
  2. Select Show Applications from the dock.
  3. Search for Visual Studio Code or Code.
  4. Click the launcher icon to start the editor.

Update Visual Studio Code on Ubuntu

Update VS Code from Microsoft APT Repository

Refresh package metadata, then upgrade only the Stable VS Code package:

sudo apt update
sudo apt install --only-upgrade code

For Insiders, target the Insiders package instead:

sudo apt update
sudo apt install --only-upgrade code-insiders

You can also use your normal system upgrade workflow, but targeted upgrades keep the action limited to VS Code.

Update VS Code from Snap

Snap refreshes installed applications automatically. To request an immediate Stable package refresh, run:

sudo snap refresh code

For Insiders, run:

sudo snap refresh code-insiders

Update VS Code from Flatpak

Update only the VS Code Flatpak package with:

sudo flatpak update com.visualstudio.code -y

Update all system-scope Flatpak applications and runtimes with:

sudo flatpak update -y

Remove Visual Studio Code from Ubuntu

Remove VS Code from APT

Remove the Stable APT package and its package-level configuration with:

sudo apt purge code

For Insiders, purge the Insiders package:

sudo apt purge code-insiders

The Microsoft package scripts remove the managed /etc/apt/sources.list.d/vscode.sources file and /usr/share/keyrings/microsoft.gpg keyring when the package is removed or purged. If you installed both Stable and Insiders but removed only one, verify the remaining package still has a Microsoft repository candidate before assuming the source should be gone. Refresh APT metadata first, then check whether the removed Microsoft source still offers a live candidate:

sudo apt update
apt-cache policy code code-insiders

If you want to confirm the Stable package is not installed after purging it, use an installed-state filter. Replace code with code-insiders if you removed Insiders:

dpkg -l code 2>/dev/null | grep '^ii' || echo "code is not installed"

Expected output:

code is not installed

If APT reports orphaned packages after removal, preview the cleanup first because reused desktop systems can have unrelated packages marked as automatic:

sudo apt autoremove --dry-run

Run the real cleanup only after reviewing the package list:

sudo apt autoremove

Remove VS Code from Snap

Remove the Stable Snap package and skip Snap’s recovery snapshot with:

sudo snap remove --purge code

For Insiders, run:

sudo snap remove --purge code-insiders

Expected output for the Stable package:

code removed

Remove VS Code from Flatpak

Remove the system-scope VS Code Flatpak package with:

sudo flatpak remove com.visualstudio.code -y

Then remove unused Flatpak runtimes and extensions that no remaining app needs:

sudo flatpak remove --unused -y

Confirm the application no longer appears in the system Flatpak app list:

sudo flatpak list --app --columns=application | grep -Fx com.visualstudio.code || echo "VS Code Flatpak is not installed"

Expected output:

VS Code Flatpak is not installed

Remove VS Code User Data

The following commands permanently delete VS Code settings, extensions, workspace storage, and caches for your user account. Back up any configuration you want to keep before running them.

For the APT Stable package, remove the common Stable profile and extension directories:

rm -rf ~/.config/Code ~/.cache/Code ~/.local/share/Code ~/.vscode

For the Snap Stable package, also remove Snap’s per-app user directory:

rm -rf ~/snap/code

For the Flatpak package, remove the Flatpak sandbox data directory:

rm -rf ~/.var/app/com.visualstudio.code

For Insiders builds, remove the Insiders profile and extension directories:

rm -rf ~/.config/Code\ -\ Insiders ~/.cache/Code\ -\ Insiders ~/.local/share/Code\ -\ Insiders ~/.vscode-insiders ~/snap/code-insiders

Troubleshoot VS Code Installation on Ubuntu

APT Cannot Locate the code Package

If sudo apt install code reports that the package cannot be located, APT has not read the Microsoft repository yet or the source file was removed. Recreate the source file, run sudo apt update, and verify the candidate again:

sudo apt update
apt-cache policy code

A working setup shows a candidate from https://packages.microsoft.com/repos/code. If the candidate remains empty, recheck the signing key path, the Signed-By line, and network access to the Microsoft repository metadata.

VS Code PPA Searches on Ubuntu

Searches for a VS Code PPA usually refer to the same need: installing an upstream package through APT. Microsoft does not maintain a Launchpad PPA for Visual Studio Code, so do not use add-apt-repository for this editor. Use the Microsoft packages.microsoft.com source configured in the APT section instead.

Direct Download vs Repository Install

The direct .deb download is useful for a one-off graphical install, and Microsoft’s package can add the APT repository during installation. For repeatable command-line setup, the repository commands are easier to audit, rerun, update, and remove.

Official Visual Studio Code Resources

Conclusion

With VS Code installed, Ubuntu can handle everyday editing, extension-based language support, Git workflows, and terminal-driven development from one desktop app. Keep the package source aligned with the method you chose, then build out the rest of your environment with install Git on Ubuntu or install Node.js on Ubuntu if your projects need JavaScript tooling.

Follow LinuxCapable

Want more LinuxCapable guides in Google?

Add LinuxCapable as a preferred source so Google can show more of our fresh Linux tutorials in Top Stories and From your sources when relevant.

Add LinuxCapable as a preferred source on Google
Search LinuxCapable

Need another guide?

Search LinuxCapable for package installs, commands, troubleshooting, and follow-up guides related to what you just read.

Found this guide useful?

Support LinuxCapable to keep tutorials free and up to date.

Buy me a coffeeBuy me a coffee
Before commenting, please review our Comments Policy.
Formatting tips for your comment

You can use basic HTML to format your comment. Useful tags currently allowed in published comments:

You type Result
<code>command</code> command
<strong>bold</strong> bold
<em>italic</em> italic
<blockquote>quote</blockquote> quote block

Got a Question or Feedback?

We read and reply to every comment - let us know how we can help or improve this guide.

Let us know you are human: