If you're a Ubuntu Linux user and looking for a versatile code editor, you're in the right place. Visual Studio Code, often referred to as VS Code, is a powerful and highly customizable code editor developed by Microsoft. In this guide, we'll walk you through the step-by-step process of installing VS Code on your Ubuntu system — three different ways, with updates, uninstall, and troubleshooting included.
Short on time? Here are the three commands that cover 95% of cases. Pick one:
- Snap (easiest):
sudo snap install --classic code - APT + Microsoft repo (my pick for developers): add the GPG key and repo, then
sudo apt install code - .deb download: grab the file from the official site and run
sudo apt install ./file.deb
👉 Explore our comprehensive list of the Best code editors for all programmers to find the perfect one for your coding needs!
📌 What Is Visual Studio Code?
Visual Studio Code, commonly known as VS Code, is a free and open-source code editor that has gained immense popularity within the developer community. It's packed with features designed to enhance productivity and streamline the coding process. Some of its key features include:
- Intelligent Code Editing: VS Code offers smart, context-aware code completion and suggestions, making coding faster and more efficient.
- Versatile Language Support: It supports a wide range of programming languages, thanks to its extensive collection of extensions.
- Integrated Version Control: You can easily manage your Git repositories and perform version control tasks right from the editor.
- Customizable Interface: VS Code's user interface is highly customizable, allowing you to tailor it to your preferences with themes, extensions, and settings.
Now that you know why VS Code is a top choice among developers, let's get started with the installation process.
🔍 Before You Install
New to the ecosystem? Start with What is Ubuntu to understand the fundamentals. Two minutes here saves you twenty minutes of confused Googling later.
Check Your Ubuntu Version
lsb_release -aAnything from 20.04 onward is fine. Older than 18.04? You're on your own — Microsoft dropped support.
Check Your System Architecture
uname -mx86_64 means amd64. aarch64 means arm64 — common on Raspberry Pi 5, Ampere VPS instances, and ARM laptops. VS Code ships builds for both, so either way you're covered.
Refresh Your Package Lists
sudo apt updateA stale package cache is the single most common reason installs fail. You'll also need sudo access. If you're doing this on a remote box, you'll want a working SSH session first.
📊 Which VS Code Installation Method Should You Use?
| Method | Best For | Command/Tool | Auto Updates | Difficulty |
| Snap | Beginners, quick desktop setups | snap install --classic code |
Yes, automatic | Easiest |
| APT (Microsoft repo) | Developers who manage packages centrally | apt install code |
Yes, via apt upgrade |
Moderate |
| .deb package | Offline installs, specific versions | dpkg / apt install ./file.deb |
Yes (repo is auto-added) | Moderate |
| Ubuntu Software (GUI) | People who hate the terminal | Point and click | Yes | Easiest |
My honest opinion: use APT. Snap works, but the sandboxing occasionally trips over things like external terminals and file-picker dialogs. APT installs behave like every other package on the system, which is what you want when you're already juggling Docker and language runtimes.
🛠️ Installing the VS Code Snap Package Through the Ubuntu Terminal
Snap packages are a convenient way to install software on Ubuntu, and Visual Studio Code is no exception. Here's how you can install it using the terminal:
- Open the Terminal: Launch the terminal by pressing
Ctrl + Alt + Tor searching for "Terminal" in the applications menu. - Update APT: Run the following command to make sure your package list is up to date:
sudo apt update
sudo snap install --classic code
codeThe --classic flag isn't optional. VS Code needs access outside the snap sandbox to run compilers, debuggers, and shell tasks. Leave it out and the install will simply refuse.
Snap keeps the editor updated in the background, which is genuinely convenient. The downside: first launch is slower, and the confinement can annoy you when integrating with system tools.
🛠️ Installing VS Code Using APT on Ubuntu
If you prefer using APT for package management, this is the method Microsoft documents. Run the commands in order:
Install Dependencies and Import the Microsoft GPG Key
sudo apt install wget gpg apt-transport-https -y
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.gpgWhy the keyring dance? Modern APT rejects keys dumped into apt-key. The key lives in /etc/apt/keyrings/ and the repo line points at it explicitly.
Add the VS Code Repository
echo "deb [arch=amd64,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 > /dev/nullInstall and Verify
sudo apt update
sudo apt install code -y
code --versionYou should see three lines: version number, commit hash, and architecture. If apt update throws a signature error, your key path and the signed-by value don't match. Recheck both.
📦 How to Download VS Code for Ubuntu as a .deb File
Search "download VS Code for Ubuntu" and this is what you're after. Head to the official VS Code Linux setup page, pick the .deb build matching your architecture, then install it:
sudo apt install ./code_*_amd64.debOr the old-school way, with a dependency repair pass:
sudo dpkg -i code_*_amd64.deb
sudo apt -f installNice detail: the .deb automatically registers the Microsoft repository, so future updates come through apt anyway.
Installing Visual Studio Code Using the GUI
If you prefer a graphical user interface (GUI), you can install VS Code using the Ubuntu Software Center:
- Open the Ubuntu Software Center: Search for "Ubuntu Software" in your applications menu and open it.
- Search for VS Code: In the software center, search for "Visual Studio Code."
- Install VS Code: Click on the Visual Studio Code entry and then click the "Install" button. That's the Snap build under the hood.
- Launch VS Code: Once the installation is complete, you can launch VS Code from your applications menu.
Prefer a full graphical remote desktop instead? Here's how to set up Ubuntu RDP for GUI access.
🚀 Launch VS Code and Take the First Steps
Type code to open the editor. Type code . inside a project directory to open that folder directly — this becomes muscle memory fast. Check the build with code --version. Then install extensions: press Ctrl+Shift+X, search, click Install. For a fresh setup I'd grab Python, ESLint, GitLens, and Docker.
Git integration works out of the box once Git is installed. If it isn't, our guide on installing Git on Ubuntu takes about a minute to follow.
🔗 Explore more essential Linux commands in our comprehensive guide on Mastering Linux Commands to enhance your command-line skills.
🔄 How to Update VS Code on Ubuntu
Snap installs:
sudo snap refresh codeAPT and .deb installs (both use the Microsoft repo):
sudo apt update
sudo apt upgrade code⚠️ Common VS Code Installation Errors on Ubuntu
E: Unable to locate package code
The most reported error, and it means one thing: APT doesn't know about the Microsoft repository yet. Either you ran apt install code before adding the repo, or the repo file is malformed, or you never ran apt update afterward. Redo the key and repository steps above, run sudo apt update, then install again.
snap: command not found
sudo apt install snapd -ySnap ships by default on Ubuntu Desktop but is often absent on minimal server images and containers.
VS Code Installed but Won't Launch
Run code --verbose from a terminal and read the output. On Wayland sessions, GPU issues sometimes block startup — try code --disable-gpu. Also: VS Code needs a desktop environment. On a headless Linux VPS, VPS server, or Ubuntu VPS, use VS Code Remote SSH from your local machine instead.
GPG or Signature Errors
Confirm the key exists at /etc/apt/keyrings/packages.microsoft.gpg and that the path in /etc/apt/sources.list.d/vscode.list matches character for character. Delete both, redo the steps, done.
🗑️ How to Uninstall Visual Studio Code on Ubuntu
Should you ever decide to remove Visual Studio Code from your Ubuntu system, you can do so easily:
# APT version
sudo apt remove code
sudo apt purge code
sudo apt autoremove
# Snap version
sudo snap remove codeFull cleanup of settings, cache, and extensions:
rm -rf ~/.config/Code
rm -rf ~/.vscodeCareful — that wipes every extension and custom setting permanently. Skip it if you plan to reinstall.
🎯 Final Words
In conclusion, Visual Studio Code is an excellent choice for Ubuntu users who require a feature-rich and user-friendly code editor. Whether you choose to install it via Snap, APT, .deb, or the GUI, you'll be equipped with a powerful tool to enhance your coding experience on Ubuntu. Installing takes under two minutes once you know which path you're on — Snap for speed, APT for control, .deb when you need a specific build. If something breaks, the answer is almost always a missing repository or a stale package cache. Check those first, in that order. Happy coding.
Hello, everyone, my name is Lisa. I'm a passionate electrical engineering student with a keen interest in technology. I'm fascinated by the intersection of engineering principles and technological advancements, and I'm eager to contribute to the field by applying my knowledge and skills to solve real-world problems.