How to Install Visual Studio Code on Ubuntu 20.04
How to Install Visual Studio Code on Ubuntu 20.04

How to Install Visual Studio Code on Ubuntu 20.04

On this short tutorial, we will learn how to install Visual Studio Code on Ubuntu 20.04 operating system.

Introduction

Visual Studio Code is a cross-platform source-code editor made by Microsoft for Windows, Linux and macOS. It capabilities include support for debugging, syntax highlighting, intelligent code completion, snippets, code refactoring, and embedded Git. On this tutorial we will learn how to install Visual Studio Code on Ubuntu workstation.

Visual Studio Code Installation

There are two methods of installing Visual Studio Code, namely: as a snap package via the Snapcraft store or as a deb package from Microsoft repositories. Both methods will be discussed in more detail in the following subsections.

1. Install Visual Studio Code Using Snap Package

Snaps are self-contained software packages which include all dependencies needed to run the application. Visual Studio Code snap package is distributed and maintained by Microsoft.

Install Visual Studio Code via command line, by submitting command line :

$ sudo snap install --classic code

Output :

mpik@worker1:~$ sudo snap install --classic code
code 899d46d8 from Visual Studio Code (vscode✓) installed
Install VS Code via snap
Install VS Code via snap

If we prefer using GUI, just open Ubuntu Software, then search for Visual Studio Code and install the application.

2. Installing Visual Studio Code Using APT Repository

The VS Code installation using APT repository will be performed by several steps as shown below.

Update the packages index and install the dependencies, by running the following command as a user with sudo privileges :

sudo apt update
sudo apt install software-properties-common apt-transport-https wget

Output :

mpik@worker1:~$ sudo apt update
[sudo] password for mpik:
Hit:1 https://download.mono-project.com/repo/ubuntu stable-focal InRelease
Hit:2 https://apt.releases.hashicorp.com focal InRelease
Hit:3 http://security.ubuntu.com/ubuntu focal-security InRelease
Hit:4 http://us.archive.ubuntu.com/ubuntu focal InRelease
Hit:5 https://packages.cisofy.com/community/lynis/deb stable InRelease
Hit:6 https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_20.04 InRelease
Hit:7 http://us.archive.ubuntu.com/ubuntu focal-updates InRelease
Hit:8 http://us.archive.ubuntu.com/ubuntu focal-backports InRelease
Reading package lists… Done
Building dependency tree
Reading state information… Done
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
. . .
Processing triggers for libglib2.0-0:amd64 (2.64.6-1~ubuntu20.04.3) ...
Processing triggers for man-db (2.9.1-1) ...

Import the Microsoft GPG key using the following wget command :

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

and enable the Visual Studio Code repository by typing:

$ sudo add-apt-repository "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main"

Output :

mpik@worker1:~$ wget -q https://packages.microsoft.com/keys/microsoft.asc -O- | sudo apt-key add -
OK
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

Once the apt repository is enabled , install the Visual Studio Code package by submitting command line :

$ sudo apt install code

Output :

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) …

Then we will verify the VS Code by querying its version.

$ code --version

Output :

mpik@worker1:~$ code --version
1.63.2
899d46d82c4c95423fb7e10e68eba52050e30ba3
x64

3. Using Visual Studio Code

After VS Code installation was completed done, the next step is to start it for the first time. To start VS Code on Ubuntu workstation, we will use ‘Activities’ then search bar and type “Visual Studio Code” and click on the icon to launch the Visual Studio Code application.

Visual Studio Code first time use
Visual Studio Code Main Menu for the first use

Conclusion

On this short tutorial we have learnt how to install Visual Studio Code on Ubuntu 20.04 workstation. I hope this article will be helpful.

(Visited 119 times, 1 visits today)

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

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