How to Install Visual Studio Code on Linux

Visual Studio Code (VS Code) is a widely used code editor developed by Microsoft that supports several programming languages. It provides features such as syntax highlighting, debugging, and version control, making it suitable for various development needs. Being open source, it is freely available for download and installation.

One of its key advantages is its cross-platform compatibility, allowing installation on all major operating systems, including Linux, Windows, and macOS. In this tutorial, we will demonstrate how to install VSCode in Linux.

Installing VSCode on Debian-based Linux Distributions

You can use the apt package manager to install Visual Studio Code on Debian-based Linux distributions like Debian, Ubuntu, and Linux Mint. You can go through the below-listed step-by-step guidelines to install VS Code on Debian-based systems:

Step 1: Update the Package List

Before you install VSCode, update your system’s package list by running the command:

sudo apt update
updating system repositories

To avoid compatibility issues, it is recommended to check the Linux version before installing any software, such as VS Code.

Step 2: Install Required Dependencies

Let’s run the below command to install the necessary packages like apt-transport-https and software-properties-common:

sudo apt install software-properties-common apt-transport-https
Install Required Dependencies

Step 3: Download the Microsoft GPG Key

To download VSCode in Linux, download the Microsoft GPG key using the wget command, and convert it into a valid format that can be stored and used by apt:

wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg
download Microsoft gpg key

Step 4: Install the Microsoft GPG Key

After this, install the Microsoft GPG key to a trusted directory like /etc/apt/trusted.gpg.d/. Here, we use the o, g, and options to make sure the appropriate ownership and file permissions for the key:

sudo install -o root -g root -m 644 packages.microsoft.gpg /etc/apt/trusted.gpg.d/
install microsoft gpg key

Step 5: Add the Visual Studio Code Repository

Now we are all set to add the Visual Studio Code repository to our system:

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'
add vscode repository

Step 6: Install VSCode Linux

After importing the VSCode repository, update the system by executing the below-given command to refresh the package lists:

sudo apt update
update packages list

Finally, we are all set to install VSCode on Linux:

sudo apt install code
install vscode

Step 7: Access VSCode

After installation, we can access the Visual Studio Code from the application manager and use it to fulfill our coding needs:

access vscode

Installing VSCode on RedHat-based Linux Distributions

To install VS Code on RedHat-based systems like CentOS, RHEL, and Fedora, you can use the dnf package manager. Follow the steps outlined below to proceed with the VS Code installation:

Step 1: Update the System Packages

Before installing VSCode, refresh your system’s package list with the following command:

sudo dnf update

Step 2: Import the Microsoft GPG Key

Next, use the rpm command to import the Microsoft GPG key to your system:

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

Step 3: Add the Visual Studio Code Repository Configuration

After importing the Microsoft GPG key, create a repository file for Visual Studio Code using the following command:

sudo vim /etc/yum.repos.d/vstudio_code.repo

Then paste the following script into the repository file to configure the Visual Studio Code repository:

name=Visual Studio Code
baseurl=https://packages.microsoft.com/yumrepos/vscode
enabled=1
gpgcheck=1
gpgkey=https://packages.microsoft.com/keys/microsoft.asc

Step 4: Install Visual Studio Code

Finally, run the command below to install Visual Studio code on your Linux system:

sudo dnf install code

Installing Visual Studio Code on Linux via Flatpak

To install Visual Studio Code on Linux using Flatpak, start by setting up Flatpak and adding the Flathub repository. After that, install Visual Studio Code from Flathub to get the latest version, which works well across different Linux systems.

Step 1: Add the Flathub repository

Let’s run the below-given command to add the Flathub repository to your system if it doesn't already exist:

flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
add flathub repository

Step 2: Install VS Code via Flatpak

After adding the Flathub repository, execute the command below to install VS code on Linux using Flatpak:

flatpak install flathub com.visualstudio.code
install vscode

Step 3: Use VS Code in Linux

Once VS Code is installed via Flatpak, you can launch VS Code and begin working on your coding projects in Linux:

access vs code

That’s all about installing and using Visual Studio Code on Linux.

Conclusion

Visual Studio Code (VS Code) is an easy-to-use code editor for developers. It supports multiple programming languages and offers useful features like syntax highlighting, debugging, and version control. We can install and use Visual Studio code on all major operating systems. In this article, we provided simple steps to install VS Code on different Linux distributions, including Debian-based and RedHat-based systems.

We hope this guide has helped you successfully install VS Code on Linux. For a faster and smoother coding experience, consider using Ultahost's fast VPS hosting. With dedicated resources and instant access, Ultahost ensures reliable performance for even the most demanding development tasks.

FAQ

What is Visual Studio Code (VS Code)?
Is Visual Studio Code free to use?
Can I install VS Code on different operating systems?
What package manager should I use to install VS Code on Debian-based distributions?
How do I install VS Code on RedHat-based systems?
Are there any dependencies I need to install before setting up VS Code on Linux?
How can I access Visual Studio Code after installation?

Related Post

How to Fix Unable to Locate Package in Kali L

Kali Linux is a popular operating system used for secur...

How to Set Environment Variables in Linux

Environment variables play an important role in shaping...

Guide to Installing Commands on CentOS

When a Windows user switches to Linux the first thing i...

Exploring the Linux tr Command

tr is a text manipulation command in Linux/Unix that is...

How to Fix the “wget: command not found

wget is a widely renowned command-line utility in Linux...

How to Fix “ifconfig: Command not Found

Displaying the error "ifconfig: command not found" on a...

Leave a Comment