Most of the programmers prefer to code on Linux because of several reasons. The speed of the operating system, ease of installing dependencies, and low risk of security issues, all contribute to the popularity of Linux as the preferred OS for coding stuff.
Being the most popular code editor out there, VS Code is an extremely productive tool for writing code. Today we are going to take a look at some methods to install VS Code on Linux distros such as Debian, Ubuntu, Linux Mint, CentOS, RHEL, Fedora, etc.
Table of contents
What is Visual Studio Code?
Visual Studio Code is a code editor developed by Microsoft in 2015. It is commonly known as VS Code. Like any other code editor, it comes with a lot of features such as Syntax highlighting, code completion, snippets, debugging, and many more. Extensions extend the functionality of the Visual Studio Code even further.
Visual Studio Code is powered by the Monaco Editor, which is an open-source code editor library. With the help of Electron, the code editor is made available on different platforms such as Windows, Mac, and Linux. As of 2023, VS Code has over 16 million users all over the globe.
VS Code, or Visual Studio Code, is a Microsoft product. It is a source code editor that was initially developed for Windows, Linux, and macOS. The code editor also offers debugging, syntax highlighting, automatic code completion, snippets, embedded Git control, and other features.
VS Code is open-source software that has the support of an abundance of extensions that act as a version control system. And since it is open source, there is enough community support, thus facilitating project collaboration. The following article is a step-by-step guide on how to install Visual Studio Code on Linux.
Visual Studio Code is a mild source code editor that offers comprehensive overall support, beginner-friendly editing, optimum navigation tools, and code clearance. Furthermore, VS Code is open source, thus free to use.
It is based on a rich extensibility model and supports mild integration with pre-existing tools. Coming back to the editor itself, the software has integrated support for JavaScript, TypeScript, and Node.js.
It also has a rich ecosystem of extensions and plugins, making it more versatile, as these plugins offer assistance towards languages such as C++, C#, Java, Python, PHP, GO, and even runtimes like .NET and Unity.
Lastly, VS Code also offers enough customization where users can always add newer interface languages, programming languages, themes, and even debuggers. And finally, MS VS Code also provides additional services such as a database or API.
Prerequisites
The user has to fulfill a few conditions before installing VS Code on his Linux device. These are:
- A computer running on Linux.
- A stable internet connection.
- A User account with administrative privileges.
Methods to install Visual Studio Code on Linux
One can install Visual Studio Code on Linux with ease by simply following the steps we have provided below:
Method 1. Install Visual Studio Code On Linux with Snap
Snap is a software packaging and development system that was developed for Linux. It is a bundle of applications and their dependencies bunched together for the sake of installation convenience.
Thus, you can rely on Snap to install most applications on Linux with a few clicks, without going through the manual process of installing dependencies.
Step 1. Install VS Code with snap
sudo snap install --classic code
Step 2. Check if VS Code is installed
code --version
Method 2. Using The Ubuntu GUI
If you own the latest version of Ubuntu (version 17.10 or later) then you can simply use the native GUI to install a number of applications, including VS Code. All you have to do is:
- First, start by launching the Ubuntu Software Center. You can find it in the Application Menu.
- Find the Show Application icon in the bottom left corner of the screen.
- Click it to launch the Software Center.
- Now, look for VS Code in the Software Center.
- Click on the search bar and type “Visual Studio Code“.
- Click on the VS Code icon and install it.
- If needed, enter your password to authenticate the action.
- Finally, you can launch the application directly using the launch button.
Method 3. Downloading via The Official Source
You can also directly download the package from the official VS Code website. Here, you can download the .deb and .rpm packages respectively for Debian/Ubuntu and Fedora/SUSE systems.
All you have to do is go to the website, download the packages, and install them on the respective systems.
Method 4. Install Visual Studio Code on Linux Using Repositories
Similar to the previous step, you can download and install Visual Studio Code on Linux via the command terminal, using native repositories. Here are the commands required for the various distros:
On Debian/Ubuntu Based Distributions
Step 1. Open the Command Terminal
Step 2. Update the APT repository and use the APT command to install VS Code if available.
sudo apt update
sudo apt install ./<file>.deb
Note: Installing the package will automatically install the apt repository using the system’s package manager, however, you can also install them manually:
Step 3. Install the Repository and the Signing Key
sudo apt-get install wget gpg
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg
sudo install -D -o root -g root -m 644 packages.microsoft.gpg /etc/apt/keyrings/packages.microsoft.gpg
echo "deb [arch=amd64,arm64,armhf signed-by=/etc/apt/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" |sudo tee /etc/apt/sources.list.d/vscode.list > /dev/null
rm -f packages.microsoft.gpg
Step 4. Then, update the packages and install them.
sudo apt install apt-transport-https
sudo apt update
sudo apt install code
On RHEL, Fedora, and CentOS-based distributions
Step 1. Open the Command Terminal
Step 2. Use the RPM Command to import the package on your system.
sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
Step 3. Then, use the Echo Command to install the package:
echo -e "[code]\nname=Visual Studio Code\nbaseurl=https://packages.microsoft.com/yumrepos/vscode\nenabled=1\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" | sudo tee /etc/yum.repos.d/vscode.repo > /dev/null
Step 4. Now, update the package:
NOTE: If you are using a current version, i.e. Fedora 22 or above, you can use the DNF command otherwise on older versions, you can run YUM:
dnf check-update
Or, on older systems:
yum check-update
Step 5. Finally, install VS Code using either DNF or YUM command:
sudo dnf install code
Or, on older systems:
sudo yum install code
On openSUSE and SLE-based distributions
You can also use the YUM repositories to install Visual Studio Code on openSUSE systems. Here’s how:
Step 1. Open the command terminal and use the RPM command to fetch the necessary package:
sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
echo -e "[code]\nname=Visual Studio Code\nbaseurl=https://packages.microsoft.com/yumrepos/vscode\nenabled=1\ntype=rpm-md\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" |sudo tee /etc/zypp/repos.d/vscode.repo > /dev/null
Step 2. Now, update the package and install it using the ZYPPER command:
sudo zypper refresh
sudo zypper install code
On Arch Linux using The AUR Package
You can use the following command to install VS Code on Arch Linux and its derivatives like Manjaro.
Step 1. First, launch the command terminal and then fetch the files from Git using the following command:
git clone https://aur.archlinux.org/visual-studio-code-bin.git
Step 2. Then, Make the package using the CD command:
cd visual-studio-code-bin
Step 3. Finally, install the package using MAKEPKG:
makepkg -si
Method 5. Using The Official VS Code Repository To Build The Package
You can use the official website to build the VS Code package manually.
Step 1. First, open the command terminal and configure the repository:
sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
sudo sh -c 'echo -e "[code]\nname=Visual Studio Code\nbaseurl=https://packages.microsoft.com/yumrepos/vscode\nenabled=1\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/yum.repos.d/vscode.repo'
Step 2. Then install the VS Code application using the following commands:
sudo dnf check-update
sudo dnf install code
Note: You can also use the YUM or ZYPPER commands if needed.
Method 6. Using The Binary Archive
It is yet another manual installation for VS Code. All you have to do is:
Step 1. Download the Binary Archive:
wget https://update.code.visualstudio.com/latest/linux-x64/stable -O vscode.tar.gz
Step 2. Use Tar to compile the package and CD to build it.
tar -xvf vscode.tar.gz
cd VSCode-linux-x64
Step 3. Install VS Code:
./code
Method 7. Using Flatpak to install VS Code on Linux
Step 1. First, install Flatpak on the system:
sudo apt install flatpak
Step 2. Then install VS Code:
flatpak install flathub com.visualstudio.code