If you are getting started with software development and want to install VS Code on Ubuntu to write, test, and debug code, you can follow either of the two methods explained in this tutorial.
Visual Studio Code (VS Code) is a popular code editor that offers excellent support for programming languages, extensions, debugging tools, and version control. Using VS Code on Linux provides convenient access to native development tools, command-line utilities, and package managers.
Another advantage is container integration. Linux runs Linux containers directly on its kernel, while Windows and macOS commonly use a virtual machine for Linux containers. This can simplify development workflows and reduce virtualization overhead in some scenarios, although actual performance depends on your configuration and workload.
There are several ways to install VS Code on Ubuntu, but the two methods covered in this tutorial are easy to install and manage. Coders can also try GoLang by installing GoLang on Ubuntu and start working on it.
Let’s get started!
Note: Follow only one of the installation methods below to avoid installing separate APT and Snap versions of VS Code on the same machine.
Table of Contents
- Prerequisites
- Method 1 – How to Install VS Code on Ubuntu with APT
- Step 1 – Updating the System
- Step 2 – Install Required Packages
- Step 3 – Create APT keyring Directory
- Step 4 – Download and add Microsoft's signing key
- Step 5 – Add VS Code Repository
- Step 6 – Update the Packages
- Step 7 – Install VS Code
- Step 8 – Launch VS Code
- Step 9 – Verify the Installation
- Step 10 – Update VS Code
- Method 2 – How to Install VS Code using Snap
- Conclusion
Prerequisites
- A PC or laptop with Ubuntu installed
- A user with root or sudo provileges
- An active internet connection.
Method 1 – How to Install VS Code on Ubuntu with APT
The first method to install VS Code is by using official APT repository. This is best for the users who prefer to use official and standard APT repositories and updates.
Step 1 – Updating the System
The first step is to update the system
sudo apt update
sudo apt upgrade -y
Step 2 – Install Required Packages
Next, let’s install the tools required to download and process Microsoft’s signing key.
sudo apt install wget gpg
Step 3 – Create APT keyring Directory
Now, lets create a keyring directory which will keep all the gpg keys
sudo mkdir -p /etc/apt/keyrings
Step 4 – Download and add Microsoft’s signing key
Now we will download and add Microsoft’s gpg keys to the directory we have created in the last step. This key will verify the package signature with Microsoft signing keys used by VS Code.
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | \
gpg --dearmor | \
sudo tee /etc/apt/keyrings/packages.microsoft.gpg > /dev/null
Step 5 – Add VS Code Repository
Now add the official VS Code repository to the system
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 > /dev/null
Step 6 – Update the Packages
Refresh the package index so APT can retrieve package information from the newly added repository.
sudo apt update
Step 7 – Install VS Code
Now lets install VS Code
sudo apt install code
Step 8 – Launch VS Code
As the installation completes, lets launch it
code
You can even check the current directory as a project
code .
Step 9 – Verify the Installation
Lets check the version of the installation to verify
code --version
Step 10 – Update VS Code
In future, you may need to update the VS Code package. You can easily do that with
sudo apt update
sudo apt install --only-upgrade code
Here, “sudo apt update” refreshes package information, while “sudo apt install –only-upgrade code” upgrades VS Code if an update is available.
With this the installation method 1 is completed
Method 2 – How to Install VS Code using Snap
In the second method, we will use snap instead of APT to install VS Code. This method is quick and does not need to add Microsoft’s gpg keys manually.
Step 1 – Update the System
The first step is to update the system
sudo apt update
sudo apt upgrade -y
Step 2 – Install Snap
Now lets install Snap which will futher install VS Code. In recent versions of Ubuntu, you will get snap pre-installed. If its installed already, while executing the below command APT will report that Snap is already installed or already at its newest version, depending on the system.
sudo apt install snapd
Step 3 – Install VS Code
Now lets install VS Code using Snap with classic confinement. The --classic option installs VS Code with classic confinement, allowing the application broader access to the host system than a conventionally confined Snap package.
sudo snap install --classic code
Unlike the APT method, this installation does not require you to configure Microsoft’s signing key manually. Snap handles package distribution and verification through its own infrastructure.
Step 4 – Launch VS Code
Now lets launch VS Code
code
Lets check the current project directory
code .
Step 5 – Verify the Installation
We can verify the installation by checking the version of code
code --version
Since, Snap manages the updates automatically, you dont need to worry about that in the future.
Conclusion
With the above mentioned 2 methods, you will be able to install VS Code on Ubuntu. Although, both the methods are good and easy but if you are an absolute beginner, i recommend Method 2 as its easy, you dont have to manually update VS Code and nor add Microsoft’s gpg keys manually.
Frequently asked questions
How do I uninstall VS Code from Ubuntu?
The uninstall command depends on how you installed VS Code. If you used APT, run:sudo apt remove code
If you installed it using Snap, run:sudo snap remove code
These commands remove VS Code but generally leave your user settings and extensions intact.
Can I use the same VS Code installation method to update Visual Studio Code on Ubuntu?
The update process depends on how you installed VS Code. If you installed it using APT, run sudo apt update followed by sudo apt install --only-upgrade code to install the latest available version. If you installed it using Snap, updates are generally handled automatically by Snap.