How to install VS Code in Ubuntu Linux via terminal?

VS Code or Visual Studio Code can be installed on Ubuntu Linux easily using the command terminal, however apart from that GUI “software center” can also be used.

What is VS Code that we are about to use in Ubuntu?

To provide a feature-rich code editor to programmers, Microsoft has developed VS Code, which can be used on all popular operating systems using Linux. It offers syntax highlighting, intelligent code completion, debugging, version control, and extensions for many programming languages and frameworks. Further, using its in-built terminal developers can execute various commands and scripts directly from the interface of the Code editor.

Using the VS code de-bugging support for various programming languages and frameworks it becomes easy to correct the code right from the Editor, also custom debugging configurations can be done.  Where to extend the functionality of the editor and increase productivity, it also supported various extensions.

Built-in support for version control systems like Git, intelligent code completion, code navigation, and the ability to customize keybindings and other features that help developers write code faster and with fewer errors make VS Code a popular choice among developer communities.

Steps to install VS Code using Terminal on Ubuntu Linux

There are multiple ways to install VS code using the terminal on Ubuntu Linux such as SNAP, APT package repository, or Debian Binary package, here we discuss all of them.

#1st method using Deb package:

Download VS Code Deb Binary

It is the best way to install VS code using the terminal because this will automatically add the package repository of VSCode on our system for future updates.

You can get the binary from the official website or by using the given command:

wget -O vscode.deb 'https://code.visualstudio.com/sha/download?build=stable&os=linux-deb-x64'

Install VScode using Terminal on Ubuntu

Now, we have the executable file, let’s use the DPKG tool to install the downloaded Debian binary of VS Code on Ubuntu Linux.

sudo dpkg -i vscode.deb

#1st method using APT package manager:

Execute APT Update

Start with the system updating process to ensure available security updates are installed on your Ubuntu system. Further, this will also rebuild the APT cache.

sudo apt update

Add Visual Studio Code GPG Key and repository

We need to add a key that has been used to sign the packages of this coding platform. Otherwise, the system will not accept the VSCode repository to download the required packages.

sudo apt-get install wget gpg
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg
sudo install -D -o root -g root -m 644 packages.microsoft.gpg /etc/apt/keyrings/packages.microsoft.gpg

Now add the repository

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'
rm -f packages.microsoft.gpg

Run system update

To ensure that the system could recognize the newly added repo packages, run the system update command once:

sudo apt update

Command to install Visual Studio Code

Finally, run a single command to get the packages on your Ubuntu system to install VS Code:

sudo apt install code

3rd method using the SNAP package

Open Terminal

Go to your Ubuntu Linux system and open your command terminal, the shortcut key is Ctrl+Alt+T.

Install VSCode Snap Package

Another easy way to install VSCODE using Terminal on Ubuntu is with the help of the Snap package manager. It is a default universal package manager available on Ubuntu Linux systems.

Here is the single command to run it on terminal:

sudo snap install code --classic

Run the Code Editor

Go to All Applications, search for VScode and when its icon appears, click to run the same.

USe command terminal to install VSCode in Ubuntu Linux 1

Uninstall or Remove

Well, there is always a point when you don’t require any installed application, and if the same goes for VSCode then here are the commands to completely remove it.

If you have installed using Debian binary or APT package manager:

sudo apt autoremove --purge code

To remove APT repository as well:

sudo rm /etc/apt/sources.list.d/vscode.*
sudo rm /etc/apt/trusted.gpg.d/ms_vscode_key.gpg

Those who have used the SNAP package manager can run:

sudo snap remove code

Other Articles:

1 thought on “How to install VS Code in Ubuntu Linux via terminal?”

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.