Visual Studio Code is a free and powerful source-code editor made by Microsoft for Windows, Linux, and macOS. VSCode offers many features such as support to debug applications, embedded Git control which helps you with code completion or refactoring when needed (it even has snippets!), plus much more! You can find extensions in this extensive library that further enhance your software development experience.
In the following tutorial, you will learn how to Install Visual Code Editor (VS CODE) on Debian 11/10 using the command line terminal to import the Microsoft official repository and gpg key and install the IDE editor, along with how to maintain and remove the software if required in the future.
Table of Contents
The following tutorial was done with a Debian 11 Bullseye release and example images taken, but it was tested on Debian Buster. In the future, if Debian makes any changes to break the tutorial for one of the distribution versions, please place a comment for me to investigate so I can update the tutorial.
Recommended Steps Before Installation
Firstly, it is advised to update your system to ensure all existing packages are up to date to avoid any conflicts during the installation.
Before proceeding with the tutorial, ensuring your system is up-to-date with all existing packages is good.
sudo apt update
Optionally, you can list the updates for users who require review or are curious.
sudo apt --list upgradable
Proceed to upgrade any outdated packages using the following command.
sudo apt upgrade
Import Visual Studio Code Repository on Debian Linux
Install Required Packages
The following packages must be installed to assist in installing the software.
sudo apt install dirmngr ca-certificates software-properties-common apt-transport-https curl -y
These are the most common software packages found on nearly all Linux distributions.
Import GPG Key & Repository
First, you will need to import the Microsoft GPG key to verify the authenticity of the installation package.
curl -fSsL https://packages.microsoft.com/keys/microsoft.asc | sudo gpg --dearmor | sudo tee /usr/share/keyrings/vscode.gpg
Secondly, import the Microsoft Visual Source Repository with the following command in your terminal.
echo deb [arch=amd64 signed-by=/usr/share/keyrings/vscode.gpg] https://packages.microsoft.com/repos/vscode stable main | sudo tee /etc/apt/sources.list.d/vscode.list
Install Visual Studio Code on Debian Linux
With the source repository sorted, you must refresh your apt package manager sources list to reflect the new addition before the Visual Studio installation.
Run the following command in your terminal to reflect the newly added repository.
sudo apt update
Next, install the VSCode version you prefer, with most users selecting the stable version. However, for those that want to test the bleeding-edge version, install the insiders build, which is the beta.
sudo apt install code -y
Install VSCode Insiders (Beta)
sudo apt install code-insiders -y
Note that you can install both versions as they share separate installations.
Launch Visual Studio Code on Debian Linux
Now that you have completed the installation, you can open the software in a few ways.
Using the command line terminal, you can open the software quickly by using the following command.
The best way to use VSCode for desktop users that prefer not to use the command line terminal is to open the GUI of the application by following the path.
Activities > Show Applications > Visual Studio Code
Once open, you can begin to use the IDE editor.
Select the theme you want. Dark is the default and is the most popular, but the tutorial white will be chosen to change the default.
Click Mark Done on the bottom left-hand side.
Congratulations, you have installed Microsoft Visual Studio Code.
Remove Visual Studio Code on Debian Linux
To remove the Visual Studio software from your system, run the following command in your terminal.
sudo apt remove code --purge
Note that the –purge flag removes all data created with VSCode.
Remove VSCode Insiders (Beta)
sudo apt remove code-insiders --purge
Next, remove the repository using the following command.
sudo rm /etc/apt/sources.list.d/vscode.list
For good housekeeping and security, remove the GPG key as follows.
sudo rm /usr/share/keyrings/vscode.gpg