How to install Visual Studio Code on Linux distributions

Install Visual Studio Code On Linux

Microsoft’s Visual Studio Code is perhaps the most widely used coding application available on all the desktop platform including Windows, macOS, and Linux. It allows the developers to code in many languages, such as Python, Go, Java, C, C++, and many more from a single application. Although you can use any text editor for coding, VS Code allows you to run various extensions which can guide you while you write the code if you have specified the language.

Also read: VSCodium – An Open-Source Alternative for Visual Studio Code

Visual Studio Code Interface
Visual Studio Code Interface

In this tutorial, I will guide you through the installation process of this application on every major Linux distribution.

Installing Visual Studio Code

Open a Terminal window and type the following commands, depending upon your Linux distribution

On Debian and Ubuntu-based distributions:

Let’s first enable the VS Code repository, and then we can directly install it using the apt package manager. But first, let’s install the dependencies :

sudo apt update && sudo apt install software-properties-common apt-transport-https

Now, using the wget utility, we will download the repository and import the GPG keys using the following commands :

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/

sudo sh -c 'echo "deb [arch=amd64 signed-by=/etc/apt/trusted.gpg.d/packages.microsoft.gpg] https://packages.microsoft.com/repos/vscode stable main" > /etc/apt/sources.list.d/vscode.list'

Finally, update the cache and install Visual Studio Code by typing :

sudo apt update && sudo apt install code

On Fedora Workstation:

Again, we will have to import the GPG keys using :

sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc

Now, let’s add the VS Code repository content to our repository lists :

cat <<EOF | sudo tee /etc/yum.repos.d/vscode.repo
[code]
name=Visual Studio Code
baseurl=https://packages.microsoft.com/yumrepos/vscode
enabled=1
gpgcheck=1
gpgkey=https://packages.microsoft.com/keys/microsoft.asc
EOF
Import The GPG Keys And Add The Repository
Import The GPG Keys And Add The Repository

Finally, you can install VS Code by typing:

sudo dnf install code
Installing Visual Studio Code On Fedora
Installing Visual Studio Code On Fedora

On Arch Linux:

Visual Studio Code is available in the Arch User Repository (AUR), so you can install it using your favorite AUR helper such as yay or paru by typing the following commands in the Terminal :

# For yay users
yay -S visual-studi-code-bin

# For Paru users
paru -S visual-studi-code-bin

Summary

If you really want to use Microsoft’s application for coding then I will recommend you VSCodium, the User interface is pretty much the same and telemetry is disabled by default, therefore, making it more privacy-friendly.

References

VS Code – Arch Wiki

Official VS Code Documentation