Install Visual Studio Code on Ubuntu 22.04 [Step-by-Step]

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/refactoring is an application that lets you build and debug modern web and cloud applications.

In this article, let's examine the installation methods on Ubuntu 22.o4.

Advertisement

 

Different methods to Install Visual Studio Code on Ubuntu 22.04

We will install on Ubuntu with 4 different methods. After reviewing the article, you can continue with the method(s) you want.

 

Method-1: Install From Ubuntu Software Centre (From Snap Store)

Visual Studio Code can be installed with Ubuntu Software Center without using a terminal. Actually, this way of installation is installation from SNAP Store. Ubuntu Software Center pulls the package from the snap store and installs it on the system.

Open Ubuntu Software, type Visual Studio Code,

Install Visual Studio Code on Ubuntu 22.04 [Step-by-Step]

 


Click the install button on the screen that appears.

Install Visual Studio Code on Ubuntu 22.04 [Step-by-Step]


The software installation process is done with the authorized user, continue by entering your password.

Install Visual Studio Code on Ubuntu 22.04 [Step-by-Step]


Installation is completed in a few minutes depending on your internet speed.

Advertisement

Visual Studio Code

Installation completed successfully without using terminal.

 

Method-2: Installing .deb Package Manually

Download the debian package for Visual Studio Code. In our example, the file was downloaded to /home/foc/Downloads:

foc@ubuntu22:~/Downloads$ pwd
/home/foc/Downloads
foc@ubuntu22:~/Downloads$ ls
code_1.72.2-1665614327_amd64.deb

Then the downloaded package is installed with the following command:

foc@ubuntu22:~/Downloads$ sudo dpkg -i code_1.72.2-1665614327_amd64.deb
Selecting previously unselected package code.
(Reading database ... 198274 files and directories currently installed.)
Preparing to unpack code_1.72.2-1665614327_amd64.deb ...
Unpacking code (1.72.2-1665614327) ...
Setting up code (1.72.2-1665614327) ...
Processing triggers for mailcap (3.70+nmu1ubuntu1) ...
Processing triggers for gnome-menus (3.36.0-1ubuntu3) ...
Processing triggers for desktop-file-utils (0.26-1ubuntu3) ...
Processing triggers for shared-mime-info (2.1-2) ...

Hint: If it gives a package dependency error during installation, run the following command. It will install the missing dependencies.

$ sudo apt-get install -f

The package was installed and also the vscode.list file was created under the /etc/apt/sources.list.d directory. It will now also make updates from this repository.

foc@ubuntu22:~/Downloads$ ls /etc/apt/sources.list.d/
vscode.list

Repository file contents:

foc@ubuntu22:~/Downloads$ cat /etc/apt/sources.list.d/vscode.list
### THIS FILE IS AUTOMATICALLY CONFIGURED ###
# You may comment out this entry, but any other modifications may be lost.
deb [arch=amd64,arm64,armhf] http://packages.microsoft.com/repos/code stable main

After this step, you can use Visual Studio Code by typing code from the menu.

 

Method-3: Install VSC Package from the Repository

When we installed the Visual Studio Code debian (.deb) package, the key and the repository file were automatically installed by the system. You can also do this by first installing the repository and the key, then installing a package.

First install the package dependencies:

foc@ubuntu22:~$ sudo apt install wget gpg -y

Upload the repository key to the system:

foc@ubuntu22:~$ wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg

foc@ubuntu22:~$ sudo install -D -o root -g root -m 644 packages.microsoft.gpg /etc/apt/keyrings/packages.microsoft.gpg

Create the repository file:

foc@ubuntu22:~$ sudo sh -c 'echo "deb [arch=amd64,arm64,armhf signed-by=/etc/apt/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" > /etc/apt/sources.list.d/vscode.list'

File created under /etc/apt/sources.list.d/ directory.

Advertisement
foc@ubuntu22:~$ ls /etc/apt/sources.list.d/
vscode.list

Delete the .gpg file:

foc@ubuntu22:~$ rm -f packages.microsoft.gpg

Update the package list:

foc@ubuntu22:~$ sudo apt update -y

Install the code package:

foc@ubuntu22:~$ sudo apt install code -y
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following package was automatically installed and is no longer required:
systemd-hwe-hwdb
Use 'sudo apt autoremove' to remove it.
The following NEW packages will be installed:
code
0 upgraded, 1 newly installed, 0 to remove and 158 not upgraded.
Need to get 88,1 MB of archives.
After this operation, 369 MB of additional disk space will be used.
Get:1 https://packages.microsoft.com/repos/code stable/main amd64 code amd64 1.72.2-1665614327 [88,1 MB]
Fetched 88,1 MB in 46s (1.925 kB/s)
Selecting previously unselected package code.
(Reading database ... 198273 files and directories currently installed.)
Preparing to unpack .../code_1.72.2-1665614327_amd64.deb ...
Unpacking code (1.72.2-1665614327) ...
Setting up code (1.72.2-1665614327) ...
Processing triggers for gnome-menus (3.36.0-1ubuntu3) ...
Processing triggers for shared-mime-info (2.1-2) ...
Processing triggers for mailcap (3.70+nmu1ubuntu1) ...
Processing triggers for desktop-file-utils (0.26-1ubuntu3) ...

The package has been installed, the files belonging to the package have been uploaded to the system. You can access Visual Studio Code by typing code from the menu.

With this method, package updates are automatically received after installation.

 

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

This method is always applied when there is no access to the package repositories. You can use the tar.gz file from anywhere by taking it to a portable memory.

Advertisement

Now download the file by going to the Visual Studio Code official download address:

Install Visual Studio Code on Ubuntu 22.04 [Step-by-Step]


Right-click on the downloaded compressed file, click Extract Here.

Install Visual Studio Code on Ubuntu 22.04 [Step-by-Step]


Right click on executable code file --> run or double click with mouse.

Install Visual Studio Code on Ubuntu 22.04 [Step-by-Step]


With this method, Visual Studio Code installation is completed.

Install Visual Studio Code on Ubuntu 22.04 [Step-by-Step]

 

Summary

We installed with 4 different methods. Each setup has its own advantages/disadvantages. The first method may be preferred for reasons such as ease of installation, up-to-dateness and security.

If you have no previous experience with Visual Studio Code, you may want to start with this Using Node.js with Visual Studio Code [Step-by-Step] article.

Advertisement

 

References

code.visualstudio.com - Visual Studio Code on Linux

 

Didn't find what you were looking for? Perform a quick search across GoLinuxCloud

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 either use the comments section or contact me form.

Thank You for your support!!

Leave a Comment

X