Visual Studio Code is a lightweight source code editor for JavaScript, TypeScript and Node.js Applications. It also has extensions for multiple other programming languages like C++, C#, Python, PHP, Go, etc. This tutorial will help you to install Visual Studio Code editor on Ubuntu, Debian, Linuxmint, and its derivatives systems.
This tutorial covers two methods for install VS Code on Ubuntu, Debian, and Linux Mint systems.
How to Install VS Code on Ubuntu using Snap
The Visual Studio Code is officially distributed as a Snap package in the Snap Store. Also, most of the latest operating systems recommended using the Snap tool for the packages installation. With these instructions, you can install Visual Studio Code on Ubuntu, Debian, and Linux Mint systems along with its derivatives.
To install VS Code, Open a terminal (CTRL+ALT+T) and type:
sudo snap install code --classic
On successful completion of the above command, the VS code will be installed on your Debian-based system.
Alternatively, follow the next method to install Visual studio code.
How to Install VS Code on Ubuntu using PPA
Use the following instructions to install Visual Studio Code on Ubuntu, Debian and Linux Mint systems using Debian packages. The PPA is officially maintained by Microsoft.
Step 1. First of all, You need to enable a package repository in your system. Run the following command to enable Visual studio code repository to your system.
sudo sh -c 'echo "deb [arch=amd64,arm64,armhf signed-by=/etc/apt/trusted.gpg.d/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" > /etc/apt/sources.list.d/vscode.list'
Step 2. Next, Import the package signing gpg key on your system using the following command.
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg sudo install -o root -g root -m 644 packages.microsoft.gpg /etc/apt/trusted.gpg.d/
Step 3. After importing gpg key, Let’s use the below commands to install Visual Studio Code on your Debian-based system.
sudo apt-get update sudo apt-get install code
That’s it. You have successfully installed Visual Studio code on a Linux system.
Working with Visual Studio Code
Now launch the Visual Studio Code editor on your system using the graphical menu. After that create a new file or open files and directories using the File menu.
There are a large number of extensions available for Visual Studio Code like C#, Python, JavaScript, Google Chrome, etc. Install the required extensions to enhance your working experience with Visual Studio Code.
Conclusion
In this tutorial, you have learned two methods for installing Visual Studio Code on a Debian-based Linux system.
12 Comments
I think maybe you should not be adding the key to trusted.gpg.d anymore. From a askubuntu post:
“the actual problem that led to apt-key add being deprecated. The problem is not a question of appending a key to one big keyring file etc/apt/trusted.gpg vs manually putting single-key keyring files into the directory /etc/apt/trusted.gpg.d/. These two things are equivalent, and doing either one is a huge security risk.”
…
“do not add it to apt’s trusted keystore by copying it into /etc/apt/trusted.gpg.d/. Instead, put it somewhere like /usr/local/share/keyrings/. (You’ll need to create that keyrings directory first.) There’s nothing special about that location, it’s just convention that /usr/local is for stuff that’s specific to this machine, share because it’s not a binary or a library or specific to any given user, and keyrings is just a descriptive name …then edit your sources to have the appropriate signed-by= path”
https://askubuntu.com/questions/1286545/what-commands-exactly-should-replace-the-deprecated-apt-key
The code package doesn’t exist, apparently
On which OS version are you trying to install?
Very good thanks.
I am getting this error
mariappanp@lp-Mariappanp:/etc/apt/sources.list.d$ sudo curl https://packages.microsoft.com/keys/microsoft.asc | gpg –dearmor > microsoft.gpg
bash: microsoft.gpg: Permission denied
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 983 100 983 0 0 3824 0 –:–:– –:–:– –:–:– 3810
(23) Failed writing body
Thank you.
good….!!!
We don’t have permission to create a file in that specified directory /etc/apt/sources.list.d/
I am obliged for this article Rahul, I was trying to download visual studio in ubuntu for office work. I am glad I reached your article in perfect time. It helped me to do it in easy way.
Strangely there are no literature or documents found on step by step VS code installation on an Ubuntu server (AWS EC2 server) through the command line (ssh interface). The closest I got was this website. Rahul – can you please confirm these are the right set of instructions to insall VS code on an Ubuntu EC2 server through ssh ?
1. Create a new file /etc/apt/sources.list.d/vscode.list
2. Add a new line deb [arch=amd64] http://packages.microsoft.com/repos/vscode stable main
3. Run the following 4 commands
curl https://packages.microsoft.com/keys/microsoft.asc | gpg –dearmor > microsoft.gpg
sudo mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg
udo apt-get update
sudo apt-get install code
Usually, ubuntu package installation is straightforward using apt install. This looks like a bit of a drain. Any reasons for the long drawn process assuming this is the correct process?
i was installing visual studio but it is showing error”E: ailed to fetch http://dl.google.com/linux/chrome/deb/dists/stable/Release Unable to find expected entry ‘main/binary-i386/Packages’ in Release file (Wrong sources.list entry or malformed file)
E: Some index files failed to download. They have been ignored, or old ones used instead.”
This is Google chrome deb repository, which is showing this error. Just remove entry for chrome repository.