Programmers and coders are often required to interact with different programming languages and these languages require different environments to execute. But what if there is a single platform where you can code in hundreds of programming languages? To do that, you can rely on Visual Studio Code(VS Code).
VS Code is a cross-platform, lightweight code editor loaded with features such as Syntax highlighting, snippets, auto-indentation, and many others.
VS Code is also available on Ubuntu 24 and this guide aims to illustrate the methods to do so.
How to Install Visual Studio Code on Ubuntu 24.04
To install the Visual Studio Code on Ubuntu 24.04, use either of the following methods:
- The snap Package Manager
- The apt Command.
- The .deb File.
- Ubuntu’s App Center.
- Flatpak
Method 1: Installing VS Code on Ubuntu 22.04 | snap Package Manager
The “snap” in Linux refers to a package that contains all the dependencies to install a specific package. For instance, if you want to install the Visual Studio Code with all its dependencies using the snap package manager, you must use the following command:
sudo snap install --classic code
To verify the installation of Visual Studio code, execute:
code --version
To run the Visual Studio Code which is installed using the snap package manager, use the following command:
snap run code
You can update the Visual Studio Code (installed using snap), by executing the below command:
sudo snap refresh code
To remove the Visual Studio Code snap from Ubuntu 24.04, use:
sudo snap remove code
Method 2: Install VS Code on Ubuntu 24.04 | apt Package Manager
To install Visual Studio Code using the apt package manager, follow these steps:
Step 1: Update System Repositories
Before installing a new package, we recommend updating the system’s repositories using the below command:
sudo apt update && sudo apt upgrade -y
Step 2: Add Visual Studio Code GPG Key
Now add the Visual Studio Code’s GPG key using the following commands:
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
Next, use the below command to add its repository to the system:
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'
After that, update the system’s repositories using:
sudo apt update
Step 3: Install Visual Studio Code
Now to install the Visual Studio Code, execute the following command:
sudo apt install code
For upgrading the Visual Studio Code which is installed using the apt package manager, use the following command:
sudo apt upgrade code
To remove Visual Studio Code from Ubuntu 22.04 installed using the apt package manager, run the below-mentioned command:
sudo apt remove code
Method 3: Install Visual Studio Code on Ubuntu 22.04 | deb File
The .deb files are the contained packages with all dependencies, executables, and configuration files that are required to install a specific package, such as Visual Studio Code. To install Visual Studio Code using the .deb file, navigate to the official website, and download the .deb file:
After downloading the .deb file for Visual Studio Code, execute the following commands to navigate to the Downloads folder, list directories, and then install it:
cd Downloads
ls
sudo dpkg -i code_1.87.0-1709078641_amd64.deb
Note: You cannot update any package installed using the .deb file via the terminal. To get the latest version of Visual Studio Code, you must download the latest version from the website and then install it, as seen above.
Run the following command to remove/uninstall the Visual Studio Code installed using the deb file:
sudo dpkg --remove code
Method 4: Install Visual Studio Code on Ubuntu 22.04 | Ubuntu App Center
The Visual Studio Code is available on the Ubuntu’s App Center as well. To download it, open the App Center, search for “code” and then use the Install button to install it:
Note: If you installed the Visual Studio Code from the App Center, you can update and uninstall it from there as well.
Method 5: Install Visual Studio Code on Ubuntu 22.04 | flathub
The flathub is a centralized distribution platform used by developers to distribute their applications on almost every other Linux distribution, including Ubuntu 24.04. It also hosts the Visual Studio Code and you can install it on Ubuntu 24.04 by following these steps:
Step 1: Install Flathub
First, install the flathub’s repository before you can install it by executing the below command:
flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
Now install it by running the below-mentioned command:
sudo flatpak install flathub
Finally, install Visual Studio Code using the flatpak by executing the below-stated command:
flatpak install flathub com.visualstudio.code
You can update the Visual Studio Code which is installed using the flatpak via the following command:
sudo flatpak update --app com.visualstudio.code
To run the Visual Studio Code installed using flatpak, execute the following command:
flatpak run com.visualstudio.code
To remove Visual Studio Code which is installed using the flathub, run:
flatpak remove com.visualstudio.code
That’s all for installing Visual Studio Code on Ubuntu 24.04.
Final Words
To install Visual Studio Code on Ubuntu 24.04, use the snap package manager, App Center, deb file, flathub, or the apt package manager. If you want to install Visual Studio Code using the apt package manager, you must add Microsoft’s provided repository first.
Visual Studio Code is a programmer’s friend and you can install it on Ubuntu 24.04 by following the above guide.