Install Visual Studio Code Rocky Linux 9 [Step-by-Step]


Rocky Linux

Author: Omer Cakmak
Reviewer: Deepak Prasad

What is Visual Studio Code?

Visual Studio Code is a source code editor developed by Microsoft for Windows, Linux and MacOS operating systems. Debugging, embedded Git control, syntax highlighting, smart code completion, snippets, and code refactoring can all be done with Visual Studio Code.

In this article, let's examine the installation steps on the Centos successor Rocky Linux 9 distribution.

 

Prerequisite

Since Visual Studio Code is a desktop application with a graphical interface, it must have a GUI in your operating system.  If your Rocky Linux 9 operating system does not have a GUI, install the GUI with the following commands:

[root@localhost foc]# dnf -y groupinstall "Server with GUI" 
[root@localhost foc]# systemctl set-default graphical

After the above operations, the system is rebooted:

[root@rocky9 foc]# reboot now

 

Different methods to install Visual Studio Code on Rocky Linux

Method-1: Install From Visual Studio Code Repo

In this method, first, let's add the Visual Studio Code Repo key to the system:

[foc@localhost ~]$ sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc

Then create vscode.repo file under /etc/yum.repos.d directory:

[foc@localhost ~]$ 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'

Then update the package cache:

[foc@localhost ~]$ dnf check-update
Visual Studio Code                                            4.1 kB/s | 3.0 kB     00:00

And install the package:

[foc@localhost ~]$ sudo dnf -y install code
Last metadata expiration check: 0:00:20 ago on Sun 16 Oct 2022 07:20:05 PM +03.
Dependencies resolved.
==============================================================================================
 Package          Architecture       Version                           Repository        Size
==============================================================================================
Installing:
 code             x86_64             1.72.2-1665614416.el7             code             119 M

Transaction Summary
==============================================================================================
Install  1 Package

Total download size: 119 M
Installed size: 350 M
Downloading Packages:
code-1.72.2-1665614416.el7.x86_64.rpm                         1.7 MB/s | 119 MB     01:10    
----------------------------------------------------------------------------------------------
Total                                                         1.7 MB/s | 119 MB     01:10     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                      1/1 
  Installing       : code-1.72.2-1665614416.el7.x86_64                                    1/1 
  Running scriptlet: code-1.72.2-1665614416.el7.x86_64                                    1/1 
  Verifying        : code-1.72.2-1665614416.el7.x86_64                                    1/1 

Installed:
  code-1.72.2-1665614416.el7.x86_64                                                           

Complete!

Congratulations, the installation has been successfully completed.

Visual Studio Code

 

Method-2: Install From SNAP Store

Start by adding the EPEL repo for the snapd package in this method:

[foc@localhost ~]$ sudo dnf -y install epel-release

Install the snapd package from the EPEL repository:

[foc@localhost ~]$ sudo dnf install snapd -y

Enable snapd.socket:

[foc@localhost ~]$ sudo systemctl enable --now snapd.socket

Create symlink to /snap directory:

[foc@localhost ~]$ sudo ln -s /var/lib/snapd/snap /snap

Reboot the system to complete the changes:

[foc@rocky9 ~]$ sudo reboot

Install the code package from the snap repo after reboot:

[foc@localhost ~]$ sudo snap install --classic code

Install Visual Studio Code Rocky Linux 9 [Step-by-Step]

After the installation is complete, the Snap daemon automatically updates Visual Studio Code in the background. You will receive an in-product update notification when a new update is available.

 

Method-3: Installing .rpm Package Manually

You can also manually download and install the VS Code .rpm package (64 bit). The RPM file has been downloaded to /home/foc/Downloads:

[foc@localhost Downloads]$ ls
code-1.72.2-1665614416.el7.x86_64.rpm

Install the package on the system:

[foc@localhost Downloads]$ sudo dnf -y install code-1.72.2-1665614416.el7.x86_64.rpm
[sudo] password for foc: 
Last metadata expiration check: 2:09:52 ago on Sun 16 Oct 2022 06:09:27 PM +03.
Dependencies resolved.
==============================================================================================
 Package        Architecture     Version                         Repository              Size
==============================================================================================
Installing:
 code           x86_64           1.72.2-1665614416.el7           @commandline           119 M

Transaction Summary
==============================================================================================
Install  1 Package

Total size: 119 M
Installed size: 350 M
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                      1/1 
  Installing       : code-1.72.2-1665614416.el7.x86_64                                    1/1 
  Running scriptlet: code-1.72.2-1665614416.el7.x86_64                                    1/1 
  Verifying        : code-1.72.2-1665614416.el7.x86_64                                    1/1 

Installed:
  code-1.72.2-1665614416.el7.x86_64                                                           

Complete!

The following version of Visual Studio Code was installed:

[foc@localhost Downloads]$ sudo dnf list installed | grep code
code.x86_64 1.72.2-1665614416.el7 @@commandline

You can access the application by typing code in the menu.

 

Method-4: Download ".tar.gz" for Visual Studio Code

Download Visual Studio Code as .tar.gz from official download address.

Install Visual Studio Code Rocky Linux 9 [Step-by-Step]


Right click the tar.gz file and click "Extract Here".

Install Visual Studio Code Rocky Linux 9 [Step-by-Step]


Enter the VSCode-linux-x64 directory. Run the code file.
Install Visual Studio Code Rocky Linux 9 [Step-by-Step]


We have successfully run Visual Studio Code by downloading the tar.gz file.

Install Visual Studio Code Rocky Linux 9 [Step-by-Step]

 

Summary

We explained "How to install Visual Studio Code on Rocky Linux 9" with 4 different methods. The choice is yours, you can proceed with whichever method is more convenient for you.

If you haven't used Visual Studio Code before, you may want to start from this How to set up Java with Visual Studio Code [Step-by-Step] article.

 

References

code.visualstudio.com - Visual Studio Code on Linux

 

Omer Cakmak

Omer Cakmak

He is highly skilled at managing Debian, Ubuntu, CentOS, Oracle Linux, and Red Hat servers. Proficient in bash scripting, Ansible, and AWX central server management, he handles server operations on OpenStack, KVM, Proxmox, and VMware. You can connect with him on his LinkedIn profile.

Can't find what you're searching for? Let us assist you.

Enter your query below, and we'll provide instant results tailored to your needs.

If my articles on GoLinuxCloud has helped you, kindly consider buying me a coffee as a token of appreciation.

Buy GoLinuxCloud a Coffee

For any other feedbacks or questions you can send mail to admin@golinuxcloud.com

Thank You for your support!!

Leave a Comment