Introduction
In this guide, we will walk you through the process to install Visual Studio Code (VS Code) on Ubuntu 22.04 LTS. Visual Studio Code is a lightweight but powerful source code editor that runs on your desktop. It provides built-in support for JavaScript, TypeScript, and Node.js and has a rich ecosystem of extensions for other languages. Ubuntu users can easily install Visual Studio Code using the terminal with a few simple commands. This guide will cover all necessary steps to ensure a successful installation of Visual Studio Code. We will also discuss how to update and uninstall Visual Studio Code if needed.
Prerequisites
Before you begin, ensure you have the following:
- A system running Ubuntu 22.04 LTS
- Administrative access or sudo privileges
- An active internet connection.
Step 1: Update System Packages
Before you install Visual Studio Code, it is essential to update your system packages to avoid any compatibility issues. Open your terminal and execute the following command:
sudo apt update && sudo apt upgrade
This command refreshes the list of available packages and their versions, then installs the newest versions of all packages you have.
Step 2: Install Required Dependencies
Visual Studio Code requires some additional software dependencies to function correctly. Install these using the following command:
sudo apt install software-properties-common apt-transport-https wget
This command installs utilities that manage software repositories and ensure secure package transfers.
Step 3: Import Microsoft GPG Key
To install Visual Studio Code, you must add the Microsoft GPG key to your system. This key verifies that the software you download is authentic. Run the command below:
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/microsoft.gpg > /dev/null
The command downloads the Microsoft GPG key and adds it to your system’s trusted keys.
Step 4: Add Visual Studio Code Repository
Next, add the Visual Studio Code repository to your system’s software list. This repository will provide the latest stable version of Visual Studio Code:
sudo add-apt-repository "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main"
This command informs your package manager where to fetch Visual Studio Code from.
Step 5: Install Visual Studio Code
With the repository added, you can now install Visual Studio Code. Run the following command in your terminal:
sudo apt update
sudo apt install code
These commands update your package manager’s list of available packages and then install Visual Studio Code.
Step 6: Launch Visual Studio Code
After you install Visual Studio Code, you can launch it by entering the following command in your terminal:
code
This command opens Visual Studio Code, allowing you to start coding immediately.
Step 7: Verify Installation
To confirm that you correctly installed Visual Studio Code, check its version by running:
code --version
This command displays the current version of Visual Studio Code, ensuring the installation was successful.
Step 8: Update Visual Studio Code
To keep your installation of Visual Studio Code up to date, regularly check for updates. You can update it using the terminal with:
sudo apt update
sudo apt upgrade code
These commands ensure that you have the latest features and security patches.
Step 9: Uninstall Visual Studio Code
If you ever need to uninstall Visual Studio Code, you can do so easily. Use the following command:
sudo apt remove code
This command removes Visual Studio Code from your system while keeping your configuration files intact.
Step 10: Remove Configuration Files (Optional)
If you also want to delete the configuration files to completely remove Visual Studio Code, use:
sudo apt purge code
This command removes Visual Studio Code along with all configuration files, ensuring a complete uninstallation.

















