Website Vidya
Linux & ServersStep-by-Step Guide

How to Install Visual Studio Code on Ubuntu 24.04

Step-by-step guide to install Visual Studio Code on Ubuntu 24.04 LTS using the official Microsoft APT repository, Snap, and CLI code commands.

RR
Rajesh RayLead Systems Educator
Published:
6 min read
PDF Cheat Sheet
How to Install Visual Studio Code on Ubuntu 24.04
AI Executive SummaryWebsiteVidya AI

6 min read

Step-by-step guide to install Visual Studio Code on Ubuntu 24.04 LTS using the official Microsoft APT repository, Snap, and CLI code commands.

Key Highlights
  • Prerequisites and Supported Releases
  • Method 1: Installing VS Code via Official Microsoft APT Repository (Recommended)
  • Method 2: Installing VS Code via Snap Store (Canonical)
Grounded in full engineering runbookWebsiteVidya AI Engine

Software development across modern technology stacks demands a versatile, performant source code editor equipped with integrated debugging, Git source control, and a rich ecosystem of extensions. When you install visual studio code on ubuntu 24.04, you deploy a premier development environment that combines the speed of a minimalist text editor with the sophisticated language intelligence of a full-fledged IDE.

On Ubuntu 24.04 LTS, Visual Studio Code can be installed either via Microsoft's official APT repository (ensuring strict debian packaging compliance and automatic background updates) or through Canonical's Snap Store. This tutorial guides you through both installation methods, explains how to initialize the code command-line executable, and configures developer productivity settings.

Prerequisites and Supported Releases

This guide is thoroughly verified on Ubuntu 24.04 LTS (Noble Numbat) & Ubuntu 22.04 LTS. The instructions apply cleanly to cloud instances (AWS EC2, Google Compute Engine, DigitalOcean, Hetzner), bare-metal servers, and local virtual machines.

Advertisement

Before proceeding, ensure you have the following requirements satisfied:

  • An active Ubuntu 24.04 LTS desktop or server with an accessible graphical environment (or remote tunnel).
  • A user account with sudo administrative privileges.
  • An active Internet connection to download packages and extensions.
  • At least 1 GB of free disk storage for editor binaries and extensions.

Installing Visual Studio Code through Microsoft's official APT repository provides native system packaging, seamless desktop theming, and automatic updates whenever you run standard Ubuntu system upgrades.

First, install the necessary encryption and transport packages required to securely import Microsoft's software repositories.

# Update package database and install repository utilities
sudo apt update
sudo apt install -y curl gpg apt-transport-https

Importing Microsoft GPG Key into /etc/apt/keyrings

In compliance with Ubuntu 24.04 modern repository security guidelines, store the dearmored Microsoft GPG key inside the dedicated /etc/apt/keyrings/ directory.

Advertisement
# Ensure the keyrings directory exists
sudo install -m 0755 -d /etc/apt/keyrings

# Download and dearmor Microsoft's public GPG signing key
curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | sudo tee /etc/apt/keyrings/packages.microsoft.gpg > /dev/null

# Set correct read permissions
sudo chmod 0644 /etc/apt/keyrings/packages.microsoft.gpg

Configuring the VS Code APT Source Definition

Create the repository definition file pointing to the newly imported keyring.

# Add the VS Code repository source file
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

Updating Package Lists and Installing the Code Package

Refresh your local APT cache and install the code package.

# Refresh repository index
sudo apt update

# Install Visual Studio Code
sudo apt install -y code

Method 2: Installing VS Code via Snap Store (Canonical)

The --classic flag is essential because it allows the editor to access compilers, git binaries, and SDKs installed across your host system.

# Install Visual Studio Code with classic filesystem confinement
sudo snap install --classic code

Comparing APT Repository vs Snap Package Installation

Review the differences below to select the installation channel that best aligns with your development preferences:

Advertisement
Feature / DimensionAPT Repository (Native)Snap Package (Classic)
Installation StepsRequires manual GPG key and repo setupSingle command (snap install --classic)
Update MechanismIntegrated with apt upgradeAutomated background Snap daemon updates
System IntegrationNative GTK/system file picker integrationSlightly decoupled desktop runtime
File AccessFull unrestricted host accessFull access via classic confinement
Cold Start SpeedInstantaneous launchMinimal delay on first cold launch

Step 3: Launching VS Code and Using the Command-Line Interface

You can launch Visual Studio Code from the GNOME application menu by searching for Visual Studio Code, or directly from any terminal session using the code command.

The command-line launcher allows you to open specific directories, individual files, or Git diffs directly from your current working directory.

# Open the current working directory in VS Code
code .

# Open a specific file
code /path/to/script.py

# Compare two files side-by-side using the built-in diff viewer
code --diff file1.txt file2.txt

Step 4: Managing Extensions from the Command Line

While extensions can be browsed and installed through the graphical Extensions sidebar (Ctrl+Shift+X), the code CLI provides powerful flags for automated developer workstation provisioning.

Install popular developer extensions for Python, Git, and Docker directly from your terminal.

Automating extension installations allows software teams to commit a recommended extensions list (.vscode/extensions.json) directly to their git repositories. When new developers clone the repository, VS Code prompts them to install the recommended workspace extensions with a single click, ensuring consistent linting, formatting, and language tools.

# Install Python language support
code --install-extension ms-python.python

# Install Docker management tools
code --install-extension ms-azuretools.vscode-docker

# Install GitLens for advanced git history inspection
code --install-extension eamodio.gitlens

# List all currently installed extensions
code --list-extensions

Step 5: Updating and Completely Removing Visual Studio Code

If you installed VS Code via the APT repository, the software is automatically updated during standard sudo apt upgrade runs. To remove the editor completely, execute the purge command.

# If installed via APT:
sudo apt purge -y code
sudo rm -f /etc/apt/sources.list.d/vscode.list
sudo rm -f /etc/apt/keyrings/packages.microsoft.gpg

# If installed via Snap:
sudo snap remove code

# Remove personal user settings, keybindings, and extension files:
rm -rf ~/.config/Code ~/.vscode

Troubleshooting and Common Errors

When configuring Ubuntu servers, unexpected permission errors, network timeouts, or lock contention can occur. Review these common issues and verified resolutions:

code: command not found after installing via APT.

Cause: The /usr/bin/code symlink was not added to PATH or the terminal session needs refreshing.

Resolution: Verify /usr/share/code/bin is in PATH or restart your shell session: hash -r.

export PATH=$PATH:/usr/share/code/bin

Error: Visual Studio Code is unable to watch for file changes in this large workspace.

Cause: The Linux inotify file watch limit (fs.inotify.max_user_watches) is set too low for large codebases.

Resolution: Increase the inotify limit in /etc/sysctl.d/99-vscode.conf and apply changes.

echo 'fs.inotify.max_user_watches=524288' | sudo tee /etc/sysctl.d/99-vscode.conf && sudo sysctl -p /etc/sysctl.d/99-vscode.conf

VS Code displays graphical glitching or black window on Wayland.

Cause: Electron hardware acceleration incompatibility with specific graphics drivers under Wayland.

Resolution: Launch VS Code with native Wayland flags or disable hardware acceleration temporarily.

code --ozone-platform=wayland --disable-gpu

Security Best Practices and Hardening

Verify repository keys are sourced exclusively from packages.microsoft.com and imported into /etc/apt/keyrings rather than deprecated global keyrings.

Review requested extension permissions carefully, as community marketplace extensions execute with the full privileges of your local user account.

Disable automatic workspace trust prompt bypasses to ensure untrusted repositories do not execute arbitrary build tasks or debug scripts upon opening.

Keep the VS Code application and all installed language servers updated regularly to patch upstream Electron and Chromium runtime vulnerabilities.

Deepen your Linux system administration skills with our related production-tested guides:

Authoritative References and Official Documentation

Frequently Asked Questions

Quick answers to common questions and configurations

4 FAQs
Yes. The official Visual Studio Code binary distributed by Microsoft is free for both personal and commercial use under the Microsoft Software License.
VS Code is compiled by Microsoft and includes proprietary telemetry, icons, and official marketplace access. VSCodium is a 100% open-source community distribution compiled directly from the MIT-licensed vscode repository without Microsoft branding or telemetry.
Yes. Install the 'Remote - SSH' extension in VS Code on your client machine. It connects seamlessly to remote Ubuntu servers, allowing you to edit files and debug processes as if they were running locally.
Run standard system updates: sudo apt update && sudo apt --only-upgrade install code. You do not need to download new .deb files manually.
RR
Written byVerified Author

Rajesh Ray

I’m Rajesh Rai, a full-stack developer, Linux administrator, and technology enthusiast passionate about making complex technology easier to understand and use.

SPAM-FREE MODERATED DISCOURSE

Join the Conversation & Perspective

Have thoughts, counterpoints, or reflections on this story? Engage directly with fellow readers and editorial contributors.

AT
MP
JV
+2

No comments on this guide yet. Be the first to share your thoughts or ask a question!

Recommended Reading10 Guides

Related Technical Guides

Tested runbooks, server administration walkthroughs, and troubleshooting guides

Featured Infrastructure PartnerUp to 75% OFF + 3 Months Free

Supercharge Your Linux & Cloud Workloads with Hostinger

Deploy high-speed NVMe KVM VPS, Docker containers, and LiteSpeed-accelerated WordPress servers in under 60 seconds with full root access, dedicated IPv4, and 24/7 technical support.

Pure NVMe SSD StorageFull Root Access & SSHFree Domain & Unlimited SSL99.9% Uptime SLA
Plans from$2.99/mo
Claim Hostinger DealAffiliate link • Special discount applied at checkout