Home Debian How to install Visual Studio Code on Debian 11

How to install Visual Studio Code on Debian 11

by Abraham
Visual Studio Code Software Code Editor

Code editors for several programming languages such as Python, C, and Java may be found in Visual Studio Code, an open-source code editor developed by Microsoft and available for free download. Even though Microsoft develops the tool, it is also available for Mac OS and Linux, making cross-system application creation considerably easier.

It also has syntax highlighting, intelligent code completion, and code refracting functions, among other things. As a result of its extensible library, it makes it easier for programmers to write code for specialized applications.

In this article guide, I will illustrate how to install Visual Studio Code on Debian 11 Bullseye. If you intend to learn more about this subject, continue reading this article guide.

Installing Visual Studio Code on Debian 11 Bullseye

There are three distinct methods we shall be using to install Visual Studio Code in this article guide:

  1. Installing via apt
  2. Installing via snap
  3. Installing a .deb package

Method 1: Installing Visual Studio Code via apt

Manual installation of the repository and key is also possible using the script below:

curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg

sudo install -o root -g root -m 644 microsoft.gpg /usr/share/keyrings/microsoft-archive-keyring.gpg

sudo sh -c 'echo "deb [arch=amd64,arm64,armhf signed-by=/usr/share/keyrings/microsoft-archive-keyring.gpg] https://packages.microsoft.com/repos/vscode stable main" > /etc/apt/sources.list.d/vscode.list'
add repo

Add repo

Finally, refresh the cache and install the Visual Studio Code package by following these instructions.

sudo apt-get install apt-transport-https

sudo apt-get update

sudo apt-get install code
install vs code

Install VS code

To launch Visual Studio using apt, run the following command:

code
code error

code error

Note: Don’t freak out if you get a similar error to the one shown in the output above after running the code command. We have provided an alternate command below that will aid you in bypassing the error.

sudo code --user-data-dir=~/root
run code as superuser

Run code as superuser

That’s all. Visual Studio Code (vscode) has successfully been installed on your Debian 11 OS.

vs code welcome screen

VS Code welcome screen

However, if this method fails to do the trick for you, then proceed and try out method 2 below:

Method 2: Installing Visual Studio Code via snap

Snap must be installed by performing the following command:

sudo apt install snapd
install snap

Install snap

Using the following instructions, you may install VS code through snap:

sudo snap install code --classic
install vs code via snap

Install VS code via snap

To launch VScode via snap, run the following command:

sudo snap run code
sudo snap run code

Sudo snap run code

Note: Don’t freak out if you get a similar error to the one shown in the output above after running the code command. We have provided an alternate command below that will aid you in bypassing the error.

sudo snap run code --user-data-dir=~/root
sudo snap run code as superuser

Sudo snap run code as superuser

Using this command, you may verify that the Visual Studio Code has been installed and working correctly.

code --version

or

code --version --user-data-dir=~/root
vs code version

VS code version

Once VScode has been installed, you can launch it using the provided commands or go to the activities section, search for Visual Studio Code, and fire it up.

vs code welcome screen

VS Code welcome screen

Method 3: Install Visual Studio Code via the .deb package

Step 1: In Debian, launch the browser.

Open whichever browser you have on your Debian Linux machine. However, Firefox is the default.

Step 2: Download the Visual Studio Code Debian Package.

The next step is to go to the official VS code website and get the package that can be installed on Debian and other Linux systems. The download page can be found here.

vs code download

VS code download

Step 3: Cd to Downloads

To begin, launch the Command Terminal. If you used a browser to download the Visual Studio code Debian file, go to “Downloads.” That’s because the file we acquire from the browser is immediately saved in it.

cd Downloads
cd downloads

cd Downloads

Now use the ls command to ascertain that the downloaded file is present. To do so, run the line of code below:

ls
list downloads

list downloads

Step 4: Install VS code via terminal

We can now install the downloaded .deb file of VS Code using either the APT package management or the DPKG tool. Simply use the command below to accomplish this.

sudo apt install ./file-name.deb

Delete the filename.deb extension and replace it with the real name of the file you downloaded.

Example:
sudo apt install ./code_1.68.1-1655263094_amd64.deb
install .deb file

Install .deb file

Once the above command finishes executing, run VS code, using the command or searching from the activities shown earlier.

Make VS Code the default editor.

If you have more than one source code editor installed on your computer, you may use the command below to designate Visual Studio Code as your default code editor.

sudo update-alternatives --set editor /usr/bin/code
make vs code default editor

Make vs code default editor

How to update Visual Studio Code

Visual Studio Code should be updated. Every month, Microsoft provides an update for Visual Studio Code. So, you may upgrade Visual Studio Code to the current version by following the instructions below.

sudo apt update

sudo apt upgrade code
update and upgrade vs code

Update and upgrade VS code

How to uninstall Visual Studio Code

Those no longer in need of Visual Studio Code on their Debian Linux systems can delete it by using the following command:

sudo apt remove code

or

sudo apt purge code -y

Conclusion

Visual studio code is a code editor that allows developers to run and modify different codes written in various programming languages. These codes may then be utilized for a variety of reasons by software programmers. It can be used on Windows, Linux, or any other operating system because it is compatible with all of them. This makes it simpler for developers to utilize the same platform to debug diverse scripts written in various programming languages.

You may also like

2 comments

Dosboot July 17, 2022 - 2:24 PM

Binary releases of Code without branding/telemetry/licensing.
https://snapcraft.io/codium

Reply
John Hughes March 22, 2023 - 11:43 AM

Why on earth are you using sudo when you’re logged on as root?

Why on earth are you logged on as root?

Why on earth are you running VS code as root, even Microsoft tell you not to do that!

Reply

Leave a Comment

fl_logo_v3_footer

ENHANCE YOUR LINUX EXPERIENCE.



FOSS Linux is a leading resource for Linux enthusiasts and professionals alike. With a focus on providing the best Linux tutorials, open-source apps, news, and reviews written by team of expert authors. FOSS Linux is the go-to source for all things Linux.

Whether you’re a beginner or an experienced user, FOSS Linux has something for everyone.

Follow Us

Subscribe

©2016-2023 FOSS LINUX

A PART OF VIBRANT LEAF MEDIA COMPANY.

ALL RIGHTS RESERVED.

“Linux” is the registered trademark by Linus Torvalds in the U.S. and other countries.