How to Install Visual Studio Code on Ubuntu

Anastasios Antoniadis

Visual Studio Code (VS Code) is a popular open-source code editor developed by Microsoft. It provides excellent features such as debugging, syntax highlighting, IntelliSense, and extensions. If you’re using Ubuntu and want to install VS Code, follow this step-by-step guide.

Prerequisites

Before installing VS Code, ensure that your system meets the following requirements:

  • A running Ubuntu system (20.04, 22.04, 24.04, or later recommended)
  • A user account with sudo privileges
  • Internet connection

Method 1: Installing VS Code Using the Official Package (Recommended)

The easiest and most reliable way to install Visual Studio Code on Ubuntu is by using Microsoft’s official repository.

Step 1: Update System Packages

Before installation, update your system package list to ensure you have the latest software versions:

sudo apt update && sudo apt upgrade -y

Step 2: Install Dependencies

VS Code requires some dependencies, so install them by running:

sudo apt install software-properties-common apt-transport-https wget -y

Step 3: Import Microsoft GPG Key

To verify the authenticity of the VS Code package, import Microsoft’s GPG key:

wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | sudo tee /usr/share/keyrings/packages.microsoft.gpg > /dev/null

Step 4: Add Microsoft Repository

Add the official VS Code repository to your system:

echo "deb [arch=amd64 signed-by=/usr/share/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" | sudo tee /etc/apt/sources.list.d/vscode.list

Step 5: Install Visual Studio Code

Now, update the package list and install VS Code:

sudo apt update
sudo apt install code -y

Method 2: Installing VS Code Using Snap

Ubuntu supports Snap packages, which provide an easy way to install and manage software.

Step 1: Install VS Code via Snap

Run the following command to install VS Code using Snap:

sudo snap install code --classic

Step 2: Verify Installation

To check if VS Code is installed successfully, run:

code --version

This command should output the installed version of VS Code.

Launching Visual Studio Code

After installation, you can launch VS Code using:

  • Terminal: Type code and press Enter.
  • GUI: Search for Visual Studio Code in the application menu and click on it.

Updating Visual Studio Code

If you’ve installed VS Code using:

  • APT (official package): Run sudo apt update && sudo apt upgrade code -y
  • Snap: Run sudo snap refresh code

Uninstalling Visual Studio Code

If you need to remove VS Code, use the appropriate command based on your installation method:

  • APT method:
sudo apt remove code -y && sudo apt autoremove -y
  • Snap method:
sudo snap remove code

Conclusion

Installing Visual Studio Code on Ubuntu is straightforward, whether using the official Microsoft repository or Snap. The official repository method is recommended for the latest updates and better system integration, while the Snap method is quicker and easier. Once installed, you can enhance your development experience by installing extensions and customizing your settings.

Anastasios Antoniadis
Find me on
Latest posts by Anastasios Antoniadis (see all)

Leave a Comment