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.

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.
- Prerequisites and Supported Releases
- Method 1: Installing VS Code via Official Microsoft APT Repository (Recommended)
- Method 2: Installing VS Code via Snap Store (Canonical)
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.
Visual Studio Code is a lightweight, extensible source code editor favored by developers worldwide. This step-by-step guide demonstrates how to install Visual Studio Code on Ubuntu 24.04 LTS using Microsoft's official APT repository and the Snap Store, configure the command-line code launcher, and install productivity extensions.
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.
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.
Method 1: Installing VS Code via Official Microsoft APT Repository (Recommended)
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.
# 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:
| Feature / Dimension | APT Repository (Native) | Snap Package (Classic) |
|---|---|---|
| Installation Steps | Requires manual GPG key and repo setup | Single command (snap install --classic) |
| Update Mechanism | Integrated with apt upgrade | Automated background Snap daemon updates |
| System Integration | Native GTK/system file picker integration | Slightly decoupled desktop runtime |
| File Access | Full unrestricted host access | Full access via classic confinement |
| Cold Start Speed | Instantaneous launch | Minimal 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.
Related Ubuntu Tutorials and Documentation
Deepen your Linux system administration skills with our related production-tested guides:
- How to Install Claude Code on Ubuntu and Linux — Integrate agentic AI coding assistants alongside your VS Code development workflow.
- How to Install Git on Ubuntu 24.04 LTS — Configure Git version control for integrated source management in Visual Studio Code.
- How to Install Node.js and npm on Ubuntu 24.04 — Deploy JavaScript and TypeScript runtimes for web development in VS Code.
Authoritative References and Official Documentation

The Linux Command Line, 2nd Edition: A Complete Introduction
Frequently Asked Questions
Quick answers to common questions and configurations
sudo apt update && sudo apt --only-upgrade install code. You do not need to download new .deb files manually.Editorial Disclosure: Website Vidya is supported by our readers. When you purchase hosting, tools, or software through our verified partner links, we may earn an affiliate commission at no extra cost to you. We only recommend solutions we trust and rigorously verify.
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.
Most Read Guides
TrendingUbuntu Server Not Booting? 10 Simple Steps to Fix It Fast
How to Create a 3D Button in HTML and CSS: Easy Steps
How to Install Python and Pip on Ubuntu 24.04 LTS
How to Install Nginx on Ubuntu 24.04
How to Install Python on Ubuntu 24.04 LTS
Related Technical Guides
Tested runbooks, server administration walkthroughs, and troubleshooting guides
Join the Conversation & Perspective
Have thoughts, counterpoints, or reflections on this story? Engage directly with fellow readers and editorial contributors.
No comments on this guide yet. Be the first to share your thoughts or ask a question!