How to install Visual Studio Code on Ubuntu 21.04

In this article we are going to learn how to install Visual Studio code also know as (VScode) on Ubuntu 21.04. Visual Studio Code is a lightweight source code editor which runs on desktops and is available to all operating systems out there. It comes with built in Javascript, Node.js and Typescript. One can do programming for almost languages with ease with Visual Studio Code. The languages supported are like, Go, PHP, C++, C#, Java, Python and also .NET.

Why do we like Visual Studio Code?

The reason VS code is such a nice tool is because of the following reasons:

  • It is available on all operating systems so it does not limit one on where to run the VS code, you can easily hit the ground running.
  • Vscode has a rich build-in developer tooling for example IntelliSense code completion and debugging which become handy when you don not know the complete code snippet. IT acts a guide and also lessen time to code.
  • VScode can be customized to suit your needs. You can customize every feature the way you wish and also you can add third party extensions easily.
  • VScode is an open source project. So it means you can contribute to the project development, also it means that you have a bigger community where you can ask questions whenever you are faced with problem.
  • VScode is built for the web. It includes great tools for web development such React JSx, JSON, SCSS,CSS, HTML and Less.

Install Visual Studio code

VScode can be installed either from the snap store or downloaded directly from source.

Install Visual Studio Code via Snap.

Snap packages can be installed directly from either the command line or through Ubuntu software repository.

Let us first update our system repository with the following command:

$ sudo apt update
$ sudo apt upgrade -y

After the update and upgrade is complete, we can install VScode classic into our system.

$ sudo snap install --classic code 
Output 
# sudo snap install --classic code 
code 6cba118a from Visual Studio Code (vscode✓) installed

We can start Visual Studio code with the following command:

$ code 
Visual Studio Code image

You will be greeted with the following:

Uninstall Visual Studio code

Now that we do not need Vscode, we can remove with the following command:

$ sudo snap remove code 
Output
# sudo snap remove code 
code removed

2. Installing Visual Studio code via wget command

This installation procedure require some dependencies to work. We are going to update our repository first

$ sudo apt update

After the update is complete then we can install the dependencies first.

$ sudo apt install software-properties-common apt-transport-https wget
Output
# sudo apt install software-properties-common apt-transport-https wget
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
software-properties-common is already the newest version (0.99.10).
software-properties-common set to manually installed.
wget is already the newest version (1.21-1ubuntu3).
wget set to manually installed.
apt-transport-https is already the newest version (2.2.4ubuntu0.1).
The following package was automatically installed and is no longer required:
  net-tools
Use 'sudo apt autoremove' to remove it.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

Let Import the Microsoft GPG key with the following command:

$ wget -q https://packages.microsoft.com/keys/microsoft.asc -O- | sudo apt-key add -
Output
# wget -q https://packages.microsoft.com/keys/microsoft.asc -O- | sudo apt-key add -
Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).
OK

Enable Visual Studio code repository with the following:

$ sudo add-apt-repository "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main"
Output
Repository: 'deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main'
Description:
Archive for codename: stable components: main
More info: https://packages.microsoft.com/repos/vscode
Adding repository.
Press [ENTER] to continue or Ctrl-c to cancel.
Adding deb entry to /etc/apt/sources.list.d/archive_uri-https_packages_microsoft_com_repos_vscode-hirsute.list
Adding disabled deb-src entry to /etc/apt/sources.list.d/archive_uri-https_packages_microsoft_com_repos_vscode-hirsute.list
Hit:1 http://mirrors.digitalocean.com/ubuntu hirsute InRelease
Hit:2 http://mirrors.digitalocean.com/ubuntu hirsute-updates InRelease                                          
Hit:3 https://repos-droplet.digitalocean.com/apt/droplet-agent main InRelease                                   
Hit:4 http://mirrors.digitalocean.com/ubuntu hirsute-backports InRelease                                        
Get:5 https://packages.microsoft.com/repos/vscode stable InRelease [3959 B]                          
Get:6 http://security.ubuntu.com/ubuntu hirsute-security InRelease [110 kB]    
Get:7 https://packages.microsoft.com/repos/vscode stable/main amd64 Packages [266 kB]
Fetched 380 kB in 1s (511 kB/s)   
Reading package lists... Done

Install Visual Studio code

We can now install VScode with the following command:

$ sudo apt install code 

To start VScode on the terminal just type code

Conclusion

We have learn how to install Visual Studio Code via snapcraft and also via the terminal. Take the easy route to install VScode which is via snap. What is important is what is in that code editor. Happy coding! You can learn more on the documentation page

About Mason Kipward

I am a technology enthusiast who loves to share gained knowledge through offering daily tips as a way of empowering others. I am fan of Linux and all other things open source.
View all posts by Mason Kipward →

Leave a Reply

Your email address will not be published.