How to Install VS Code on Ubuntu Linux

Visual Studio Code (VS Code) is Microsoft’s free code editor that has become the go-to choice for developers across languages and frameworks. Unlike traditional IDEs, VS Code combines a lightweight footprint with intelligent code completion (IntelliSense), integrated debugging, built-in Git version control, and an extensive extension marketplace. The editor supports dozens of programming languages out of the box, offers customizable themes and keyboard shortcuts, and runs smoothly on Ubuntu with minimal resource overhead.

This guide covers installing Visual Studio Code on Ubuntu using three methods: Microsoft’s official APT repository for direct upstream packages, Snap for automatic updates, and Flatpak for universal Linux compatibility. You’ll learn how to set up each method, launch VS Code, manage updates, and completely remove the installation when needed.

Choose Your Visual Studio Code Installation Method

Visual Studio Code offers three installation paths on Ubuntu, each with distinct trade-offs. Choose based on your update preferences, system integration needs, and whether you require the Insiders build for early access to experimental features.

MethodChannelBuilds AvailableUpdatesBest For
Microsoft APT RepositoryMicrosoft RepoStable, InsidersManual via apt upgradeUsers wanting direct Microsoft updates and traditional package management
SnapSnapcraftStable, InsidersAutomaticUsers preferring hands-off updates with sandboxed installation
FlatpakFlathubStable onlyManual via flatpak updateUsers wanting universal Linux compatibility with sandboxing

For most users, the Microsoft APT repository is recommended because it provides direct upstream packages and integrates with Ubuntu’s standard update workflow. Snap offers convenience through automatic updates, while Flatpak prioritizes cross-distribution compatibility but lacks the Insiders build.

The Microsoft repository uses a universal package format that works on all current Ubuntu releases, including LTS versions and interim releases. Commands shown in this guide work identically regardless of your specific Ubuntu version.

Method 1: Install VS Code via Microsoft APT Repository

Update System Packages

Before installing Visual Studio Code, update your system packages to avoid conflicts with outdated dependencies.

Run the following command in your terminal:

sudo apt update

This command synchronizes your package index with Ubuntu’s repositories. After the update completes, upgrade any outdated packages:

sudo apt upgrade

Install Required Dependencies

Next, install packages needed for repository management and secure GPG key downloads. You’ll use wget to fetch Microsoft’s signing key and gpg to process it.

Execute the following command:

sudo apt install wget gpg -y

Add Microsoft VS Code Repository

Once dependencies are installed, download Microsoft’s GPG signing key and convert it to binary format in a single command:

wget -qO- https://packages.microsoft.com/keys/microsoft.asc | sudo gpg --dearmor -o /usr/share/keyrings/microsoft.gpg

This command downloads the ASCII-armored key, converts it to binary format using gpg --dearmor, and writes it directly to the system keyring directory. The -o flag specifies the output file location. For more download techniques, see our wget command examples guide.

After that, create the repository configuration file using the modern DEB822 format:

echo "Types: deb
URIs: https://packages.microsoft.com/repos/code
Suites: stable
Components: main
Architectures: amd64 arm64 armhf
Signed-By: /usr/share/keyrings/microsoft.gpg" | sudo tee /etc/apt/sources.list.d/vscode.sources > /dev/null

Ubuntu 22.04 LTS and 24.04 LTS both support the modern DEB822 .sources format shown above. This format provides cleaner syntax and better maintainability compared to the legacy .list format.

Install Visual Studio Code

With the repository configured, refresh your package list to recognize the newly added repository:

sudo apt update

Verify that APT recognizes the Microsoft repository:

apt-cache policy code

Expected output showing the Microsoft repository:

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

Now, install the stable build of Visual Studio Code:

sudo apt install code

Alternatively, install the Insiders build for early access to experimental features:

sudo apt install code-insiders

Verify APT Installation

After installation completes, verify that VS Code is accessible by checking its version:

code --version

Expected output:

1.x.x
commit-hash...
x64

Method 2: Install VS Code via Snap

Install Snap Package Manager

For automatic updates, you can use Snap instead. First, confirm that Snap is installed on your system. Ubuntu includes Snap by default, but you can install it if needed:

sudo apt install snapd

Install VS Code Using Snap

Once snapd is ready, you can install Visual Studio Code with this command:

sudo snap install code --classic

Alternatively, for the Insiders build:

sudo snap install code-insiders --classic

The --classic flag grants full system access, which VS Code requires to function without sandbox limitations.

Verify Snap Installation

After installation completes, verify that VS Code is accessible:

snap list code

Expected output:

Name  Version       Rev    Tracking       Publisher   Notes
code  1.x.x         xxx    latest/stable  vscode✓     classic

Method 3: Install VS Code via Flatpak and Flathub

Add Flathub Repository

For universal Linux compatibility, you can use Flatpak instead. If Flatpak isn’t installed on your system, follow our Flatpak installation guide on Ubuntu to set up the Flatpak framework and Flathub repository, which typically takes under five minutes. Once ready, add the Flathub repository:

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

The --if-not-exists flag prevents errors if Flathub is already configured.

Flatpak is not pre-installed on Ubuntu. Both Ubuntu 22.04 LTS and 24.04 LTS require manual installation of Flatpak and the Flathub repository before you can install Flatpak applications. If the flatpak command is not found, complete our prerequisite guide linked above first.

Install VS Code Using Flatpak

With Flathub configured, install Visual Studio Code from the repository:

sudo flatpak install flathub com.visualstudio.code -y

This command installs Visual Studio Code system-wide for all users. The sudo prefix ensures the application is available for every account on the system.

Verify Flatpak Installation

After installation completes, verify that VS Code is installed correctly:

flatpak info com.visualstudio.code

Expected output:

Visual Studio Code - 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

Launching Visual Studio Code

Launch VS Code from Terminal

After completing the installation, you can launch Visual Studio Code from the terminal. For the stable version:

code

For the Insiders build:

code-insiders

Alternatively, for Flatpak installations, use this command:

flatpak run com.visualstudio.code

Similarly, for Snap installations, the command is:

snap run code

Alternatively, for Snap installations of the VS Code Insiders build, use:

snap run code-insiders

Launch VS Code from Applications Menu

Alternatively, to launch Visual Studio Code using Ubuntu’s graphical interface:

  1. First, click on Activities at the top left corner of the screen. This opens a dashboard with commonly used applications and an overview of your workspaces.
  2. Then, select Show Applications, represented by a grid or ‘nine dots’ icon at the bottom of the dock on the left.
  3. In the search bar, type “Visual Studio Code.” The VS Code icon appears as you type.
  4. Click on the icon to launch Visual Studio Code.

Updating Visual Studio Code

Update VS Code via APT Repository

When using the APT installation method, Visual Studio Code updates arrive through Ubuntu’s standard package update process. To update, refresh your package list and upgrade:

sudo apt update && sudo apt upgrade

This command upgrades all system packages including VS Code. Alternatively, to upgrade only VS Code specifically:

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

Update VS Code via Snap

When using Snap, the system handles updates automatically in the background. However, you can force an immediate update check:

sudo snap refresh code

For the Insiders build:

sudo snap refresh code-insiders

Update VS Code via Flatpak

For Flatpak installations, update Visual Studio Code through Flatpak’s update mechanism:

sudo flatpak update com.visualstudio.code -y

Alternatively, you can update all Flatpak applications at once:

sudo flatpak update -y

Remove Visual Studio Code

Remove VS Code via APT

If you installed Visual Studio Code via APT, use the following command to uninstall the stable build:

sudo apt remove code

Alternatively, if you installed the insider’s build, use:

sudo apt remove code-insiders

Confirm removal by typing y and pressing Enter. Then remove any orphaned dependencies:

sudo apt autoremove

Next, remove the repository configuration and GPG key to stop future update checks:

sudo rm /etc/apt/sources.list.d/vscode.sources

Finally, clean up by deleting the GPG key:

sudo rm /usr/share/keyrings/microsoft.gpg

Refresh the package cache to confirm the repository is removed:

sudo apt update

Verify the package is no longer available from the Microsoft repository:

apt-cache policy code

The command returns no output when the repository has been successfully removed, confirming the package is no longer available from Microsoft’s repository.

Remove VS Code via Flatpak

For Flatpak installations, use this command:

sudo flatpak uninstall com.visualstudio.code

Optionally, remove unused Flatpak runtimes to free disk space:

sudo flatpak uninstall --unused -y

Remove VS Code via Snap

For Snap installations, remove Visual Studio Code by executing:

sudo snap remove code

Alternatively, for the Insiders build installed via Snap:

sudo snap remove code-insiders

Remove VS Code User Data

The following commands permanently delete your VS Code settings, extensions, and cached data. If you want to preserve your configuration for future reinstallation, back up these directories first: cp -r ~/.config/Code ~/vscode-backup.

After uninstalling VS Code, you can optionally remove user data directories that contain settings, extensions, and cache:

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

For Flatpak installations, user data is stored separately:

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

For Insiders builds, remove the corresponding directories:

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

Closing Thoughts

Visual Studio Code provides intelligent code completion, integrated debugging, and extensive language support through its extension marketplace. This guide covered three installation methods—APT for upstream packages, Snap for automatic updates, and Flatpak for cross-distribution compatibility. Your Ubuntu system now has a customizable development environment ready for projects of any scale. For a complete development setup, consider installing Git for version control or Node.js for JavaScript development. Additionally, configure unattended upgrades to keep your system secure.

Official Resources

Leave a Comment