January 27, 2022
How to install Visual Studio Code on Ubuntu 20.04

How to Install Visual Studio Code on Ubuntu 20.04

On this tutorial we will learn how to install Visual Studio Code version 1.63.2 on Ubuntu 20.04.

Introduction

Visual Studio Code is a cross-platform source-code editor made by Microsoft for Windows, Linux and macOS. It capability including: support for debugging, syntax highlighting, intelligent code completion, snippets, code refactoring, and embedded Git. Users can change the theme, keyboard shortcuts, preferences, and install extensions that add additional functionality. On this tutorial, we will learn how to install Visual Studio Code on Ubuntu Linux.

Visual Studio Code Installation on Ubuntu 20.04

Visual Studio Code can be installed as a deb package from Microsoft repositories or as a snap package via Snapcraft store. In this tutorial, we will discuss how to install using both methods.

A. Installing Visual Studio Code Using APT Repository

The steps for installing Visual Studio Code using the repository will be described below. Microsoft has provided a Visual Studio Code repository and we will do the installation with the latest version of the Visual Studio Code repository. Here are the steps:

  1. Install Dependencies Packages
  2. Adding and enabling Visual Studio Code repository
  3. Install Visual Studio Code

1. Install Dependencies Packages

Before installing dependencies packages for Visual Studio Code, we will update the Ubuntu system first. By updating Ubuntu 20.04 system, it will refresh the local list of available packages software to the newer stable version. To update Ubuntu 20.04 repositories, we will use the command line :

$ sudo apt update

Then we will install the dependencies packages, by submitting command line :

$ sudo apt install software-properties-common apt-transport-https

The output will be shown below.

mpik@worker1:~$ sudo apt install software-properties-common apt-transport-https
Reading package lists... Done
Building dependency tree       
Reading state information... Done
apt-transport-https is already the newest version (2.0.6).
The following packages were automatically installed and are no longer required:
  chromium-bsu-data fonts-uralic libalut0 libglc0 libglewmx1.13 libgtkglext1 libminizip1 libopenal-data
  libopenal1 libpangox-1.0-0 libsdl2-2.0-0 libsdl2-image-2.0-0 libsndio7.0
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  python3-software-properties software-properties-gtk
The following packages will be upgraded:
  python3-software-properties software-properties-common software-properties-gtk
3 upgraded, 0 newly installed, 0 to remove and 313 not upgraded.
Need to get 101 kB of archives.
After this operation, 14.3 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 software-properties-common all 0.99.9.8 [10.6 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 software-properties-gtk all 0.99.9.8 [66.0 kB]
Get:3 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 python3-software-properties all 0.99.9.8 [24.9 kB]
Fetched 101 kB in 1s (73.3 kB/s)                  
(Reading database ... 190478 files and directories currently installed.)
Preparing to unpack .../software-properties-common_0.99.9.8_all.deb ...
Unpacking software-properties-common (0.99.9.8) over (0.98.9.5) ...
Preparing to unpack .../software-properties-gtk_0.99.9.8_all.deb ...
Unpacking software-properties-gtk (0.99.9.8) over (0.98.9.5) ...
Preparing to unpack .../python3-software-properties_0.99.9.8_all.deb ...
Unpacking python3-software-properties (0.99.9.8) over (0.98.9.5) ...
Setting up python3-software-properties (0.99.9.8) ...
Setting up software-properties-common (0.99.9.8) ...
Setting up software-properties-gtk (0.99.9.8) ...
Processing triggers for dbus (1.12.16-2ubuntu2.1) ...
Processing triggers for shared-mime-info (1.15-1) ...
Processing triggers for desktop-file-utils (0.24-1ubuntu2) ...
Processing triggers for mime-support (3.64ubuntu1) ...
Processing triggers for hicolor-icon-theme (0.17-2) ...
Processing triggers for gnome-menus (3.36.0-1ubuntu1) ...
Processing triggers for libglib2.0-0:amd64 (2.64.6-1~ubuntu20.04.3) ...
Processing triggers for man-db (2.9.1-1) ...
Installing Visual Studio Code dependencies packages
Installing Visual Studio Code dependencies packages

2. Adding and Enabling Visual Studio Code Repository

On this stage, we will add VSC repository to our Ubuntu system. This tasks will be consist of two steps:

1. Import the Microsoft GPG Key, by submitting command line :

$ wget -q https://packages.microsoft.com/keys/microsoft.asc -O- | sudo apt-key add -

2. Enabling Visual Studio Code repository, by submitting command line :

mpik@worker1:~$ sudo add-apt-repository "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main"
Hit:1 https://download.mono-project.com/repo/ubuntu stable-focal InRelease
Hit:2 https://apt.releases.hashicorp.com focal InRelease                                                                  
Get:3 https://packages.microsoft.com/repos/vscode stable InRelease [3,959 B]                                              
Hit:4 http://us.archive.ubuntu.com/ubuntu focal InRelease                                                                 
Get:5 https://packages.microsoft.com/repos/vscode stable/main amd64 Packages [276 kB]                                     
Hit:6 http://security.ubuntu.com/ubuntu focal-security InRelease                                                          
Hit:7 http://us.archive.ubuntu.com/ubuntu focal-updates InRelease                                                         
Hit:8 https://packages.cisofy.com/community/lynis/deb stable InRelease                                                    
Hit:9 http://us.archive.ubuntu.com/ubuntu focal-backports InRelease                                                       
Hit:10 https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_20.04  InRelease
Fetched 279 kB in 2s (173 kB/s)
Reading package lists... Done
Adding Microsoft Visual Studio Code repository
Adding Microsoft Visual Studio Code repository

3. Install Visual Studio Code on Ubuntu 20.04

After all are set, then we will install Visual Studio Code by submitting command line :

$ sudo apt install code

The output will be as shown below :

mpik@worker1:~$ sudo apt install code
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  chromium-bsu-data fonts-uralic libalut0 libglc0 libglewmx1.13 libgtkglext1 libminizip1 libopenal-data libopenal1
  libpangox-1.0-0 libsdl2-2.0-0 libsdl2-image-2.0-0 libsndio7.0
Use 'sudo apt autoremove' to remove them.
The following NEW packages will be installed:
  code
0 upgraded, 1 newly installed, 0 to remove and 313 not upgraded.
Need to get 81.1 MB of archives.
After this operation, 339 MB of additional disk space will be used.
Get:1 https://packages.microsoft.com/repos/vscode stable/main amd64 code amd64 1.63.2-1639562499 [81.1 MB]
Fetched 81.1 MB in 38s (2,112 kB/s)                                                                                       
Selecting previously unselected package code.
(Reading database ... 190478 files and directories currently installed.)
Preparing to unpack .../code_1.63.2-1639562499_amd64.deb ...
Unpacking code (1.63.2-1639562499) ...
Setting up code (1.63.2-1639562499) ...
Processing triggers for mime-support (3.64ubuntu1) ...
Processing triggers for gnome-menus (3.36.0-1ubuntu1) ...
Processing triggers for shared-mime-info (1.15-1) ...
Processing triggers for desktop-file-utils (0.24-1ubuntu2) ...

To verify if Visual Studio Code was successfully installed, we will run the following command line :

$ code --version

The output will as shown below :

mpik@worker1:~$ code --version
1.63.2
899d46d82c4c95423fb7e10e68eba52050e30ba3
x64
Submitting Visual Studio Code installation
Submitting Visual Studio Code installation

B. Installing Visual Studio Code Using Snap Package

As we know, if the Snap packages can be installed from either the command-line via console and the Ubuntu Software application via GUI. On this tutorial we will install Visual Studio Code using Snap packages by using command line. To install it, it is very simple, just type the command line below and all will be handled by Snap packages.

$ sudo snap install --classic code

The output will be as follow :

mpik@worker1:~$ sudo snap install --classic code
code 899d46d8 from Visual Studio Code (vscodeāœ“) installed
Installing Visual Studio Code using Snap Packages via command line
Installing Visual Studio Code using Snap Packages via command line

Launching Visual Studio Code On Ubuntu 20.04 Desktop

To start using Visual Studio Code is very simple, we just using Ubuntu Application manager to search Visual Studio Application and double click it to launch.

Launching Visual Studion on Ubuntu 20.04
Launching Visual Studion on Ubuntu 20.04

The first page of Visual Studio Code will be as shown below.

Visual Studio Code | Get Started
Visual Studio Code | Get Started

There are many extensions that have been provided in the market place that can downloaded and used to support application development, such as Python, C/C++ and others.

Visual Studio Extension
Visual Studio Extension

Conclusion

On this tutorial we have learnt how to install Visual Studio Code on Ubuntu 20.04 Linux operating system. More detailed information about Visual Studio Code can be found on the official Visual Studio Code website.

Share this article via :

Leave a Reply

Your email address will not be published. Required fields are marked *