How to Install Visual Studio Code (VS Code) on Ubuntu, Linux, and Windows Machines - Step-by-Step Guide

You can use the following methods:

Method 1: Using the Snap Package

The Snap package is available for easy installation on Ubuntu:

sudo snap install --classic code

This will install VS Code along with the --classic flag, which gives it access to more system resources.

Method 2: Using APT (Debian Package Management)

If you prefer using APT, you can install VS Code using the following commands:

  1. First, add the Microsoft GPG key to verify the packages:

     wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg
     sudo install -o root -g root -m 644 packages.microsoft.gpg /etc/apt/trusted.gpg.d/
    
  2. Then, add the Visual Studio Code repository:

     sudo sh -c 'echo "deb [arch=amd64,arm64,armhf signed-by=/etc/apt/trusted.gpg.d/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" > /etc/apt/sources.list.d/vscode.list'
    
  3. Finally, update the package list and install VS Code:

     sudo apt update
     sudo apt install code
    

    Method 3: Using the .deb Package

    You can also download the .deb package from the VS Code website and install it manually:

    1. Visit the Visual Studio Code download page using your web browser.

    2. Download the .deb package for Ubuntu.

    3. Open a terminal and navigate to the directory where the .deb package is downloaded.

    4. Install the package using the following command:

       bashCopy codesudo dpkg -i <package-name>.deb
       sudo apt install -f
      

Replace <package-name> with the actual name of the .deb package you downloaded.

After installation, you can launch Visual Studio Code by searching for it in the application menu or by running the command code in the terminal.