Visual Studio Code (VS Code) has become an indispensable tool for developers across a multitude of platforms and programming languages. Its lightweight nature, extensive extension marketplace, and powerful debugging capabilities make it a top choice for everything from web development to embedded systems programming. For Ubuntu users, installing and configuring VS Code is a straightforward process, allowing them to harness its full potential for their projects. This guide will walk you through the various methods of installing VS Code on your Ubuntu system, ensuring you can get up and running with this powerful Integrated Development Environment (IDE) efficiently.

Understanding the Installation Methods
Before diving into the installation process, it’s beneficial to understand the different approaches available. Each method offers distinct advantages, catering to different user preferences and system configurations. We’ll explore the official repositories, direct download, and the Snap package manager, providing a comprehensive overview of how to get VS Code onto your Ubuntu machine.
Installing via the Official Ubuntu Repositories
One of the most common and often recommended ways to install software on Ubuntu is through its official package repositories. This method ensures that the software is well-integrated with your system and benefits from automatic updates managed by Ubuntu’s package manager (apt).
Adding the Microsoft APT Repository
Microsoft provides an official APT repository for Visual Studio Code, which allows for seamless integration with Ubuntu’s package management system. This is the preferred method for most users who want to maintain their software through standard Ubuntu update mechanisms.
-
Import the Microsoft GPG key:
This step is crucial for verifying the authenticity of the packages you will be downloading. Open your terminal and execute the following commands: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/ rm packages.microsoft.gpgwget -qO- ...: This downloads the GPG key from Microsoft’s signing servers and pipes it togpg --dearmorfor conversion into a binary format suitable for APT.sudo install ...: This command copies the de-armored GPG key to the/etc/apt/trusted.gpg.d/directory, making it available to APT for package verification.rm packages.microsoft.gpg: This cleans up the temporary GPG key file.
-
Add the VS Code repository to your sources list:
Next, you need to tell APT where to find the VS Code packages. This is done by creating a new source list file.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'sudo sh -c '...': This command executes the inner string as a shell command with root privileges.echo "deb [...]": This line defines the new repository entry.[arch=amd64,arm64,armhf]: Specifies the supported architectures for VS Code.[signed-by=/etc/apt/trusted.gpg.d/packages.microsoft.gpg]: Links the repository to the GPG key we imported earlier, ensuring package integrity.https://packages.microsoft.com/repos/code stable main: This is the URL for the Microsoft VS Code repository.
> /etc/apt/sources.list.d/vscode.list: This redirects the output of theechocommand to a new file namedvscode.listwithin the/etc/apt/sources.list.d/directory. This is the standard location for custom APT repository configurations.
-
Update your package list and install VS Code:
After adding the new repository, you must update your local package index to include the new sources. Then, you can install VS Code.sudo apt update sudo apt install codesudo apt update: This command refreshes the list of available packages from all configured repositories, including the newly added Microsoft repository.sudo apt install code: This command installs thecodepackage, which is the Visual Studio Code package in the Microsoft repository.
Once these commands have completed successfully, Visual Studio Code will be installed on your Ubuntu system. You can launch it from your application menu or by typing code in the terminal.
Installing via Direct Download (.deb Package)
For users who prefer a more manual installation or who might be working in environments with restricted internet access for package repositories, downloading the .deb package directly from the official VS Code website is an excellent alternative. This method provides the latest stable release and is easy to install with a few clicks or terminal commands.
Downloading the Latest .deb Package
-
Visit the Official VS Code Download Page:
Open your web browser and navigate to the Visual Studio Code download page for Linux. You will typically find this athttps://code.visualstudio.com/Download. -
Select the
.debpackage:
On the download page, you will see various download options for different Linux distributions. Look for the.deboption, which is suitable for Ubuntu and Debian-based systems. Click on the download button for the.debpackage. This will download a file with a name similar tocode_1.XX.Y.Z-amd64.deb(whereXX.Y.Zrepresents the version number).
Installing the .deb Package
Once the .deb file has been downloaded, you have two primary ways to install it: using the graphical installer or the terminal.
Graphical Installation (Recommended for Ease of Use)
-
Locate the downloaded file:
Open your file manager and navigate to the directory where you downloaded the.debfile (usually yourDownloadsfolder). -
Double-click the
.debfile:
Double-clicking the.debfile will typically open it with the Ubuntu Software Center or a similar package installer application. -
Click “Install”:
In the installer window, you will see details about Visual Studio Code. Click the “Install” button. You will be prompted to enter your user password to authorize the installation.
Terminal Installation
-
Navigate to the download directory:
Open your terminal and use thecdcommand to navigate to the directory where you downloaded the.debfile. For example, if it’s in your Downloads folder:cd ~/Downloads -
Install using
dpkg:
Use thedpkgcommand to install the package. Replacecode_1.XX.Y.Z-amd64.debwith the actual name of the downloaded file.sudo dpkg -i code_1.XX.Y.Z-amd64.debsudo dpkg -i: This command installs the specified package.
-
Resolve Potential Dependency Issues:
Sometimes, installing a.debpackage directly might result in dependency errors if required libraries are not already installed on your system. If you encounter such errors, you can resolve them with the following command:sudo apt --fix-broken installThis command will attempt to find and install any missing dependencies required by VS Code. After this command completes, the installation of VS Code should be finalized.
Regardless of the method chosen, once installed, you can launch Visual Studio Code from your application menu or by typing code in the terminal.

Installing via Snap Package Manager
Snap is a universal package manager developed by Canonical, the company behind Ubuntu. Snaps package an application along with all its dependencies into a single bundle, ensuring that it runs consistently across different Linux distributions and versions. VS Code is readily available as a Snap package, offering a convenient and isolated installation.
Benefits of Using Snap
- Isolation: Snaps run in a sandbox environment, which enhances security by limiting their access to your system.
- Automatic Updates: Snap packages are automatically updated in the background, ensuring you always have the latest version without manual intervention.
- Cross-Distribution Compatibility: While this guide focuses on Ubuntu, a Snap package of VS Code will work similarly on other Snap-enabled Linux distributions.
Installing VS Code as a Snap
Installing VS Code using Snap is remarkably simple and requires only a single command in your terminal.
-
Open your terminal:
Launch your terminal application. -
Install the VS Code Snap:
Execute the following command:sudo snap install --classic codesudo snap install: This is the command to install a Snap package.--classic: This flag is important for VS Code. The--classicconfinement allows the snap to access system resources that are necessary for a full-featured IDE, such as accessing arbitrary files and running arbitrary executables. Without it, VS Code might have limitations.code: This is the name of the Visual Studio Code Snap package.
The snap install command will download the VS Code Snap package and its dependencies, and then install it on your system. This process might take a few moments depending on your internet connection speed.
Once the installation is complete, Visual Studio Code will be available in your application menu. You can also launch it from the terminal by typing code.
Post-Installation Configuration and Usage
After successfully installing Visual Studio Code, there are several steps you can take to enhance your development experience. These include customizing its appearance, installing essential extensions, and configuring your workspace.
Launching Visual Studio Code
To launch VS Code:
- From the Application Menu: Search for “Visual Studio Code” in your Ubuntu application menu and click on the icon.
- From the Terminal: Open a terminal and type
codeand press Enter. This command will open VS Code. You can also open a specific directory in VS Code by navigating to that directory in the terminal and typingcode .(the dot represents the current directory).
Exploring the User Interface
Upon launching VS Code, you’ll be greeted with a clean and intuitive interface. Key components include:
- Activity Bar: On the far left, this bar contains icons for various features like Explorer, Search, Source Control, Run and Debug, and Extensions.
- Sidebar: This area displays content related to the selected Activity Bar icon. For example, the Explorer sidebar shows your project’s file structure.
- Editor Group: The main central area where you open and edit your files. You can split the editor into multiple groups to view and edit files side-by-side.
- Panel: Located at the bottom, this area houses the Terminal, Output, Debug Console, and Problems views, providing crucial feedback and tools.
- Status Bar: At the very bottom, this bar displays information about the current file, code language, and various editor settings.
Customizing Your Workspace
VS Code is highly customizable to suit your workflow and preferences.
Themes and Color Schemes
- Changing Themes: Go to
File > Preferences > Color Theme(orCode > Preferences > Color Themeon macOS) or pressCtrl+K Ctrl+T. You can cycle through installed themes and select the one that best suits your eyes. - Installing New Themes: The Extensions view (
Ctrl+Shift+Xor click the Extensions icon in the Activity Bar) is your gateway to a vast library of themes. Search for “theme” and explore options like “One Dark Pro,” “Dracula Official,” or “Material Theme.”
Fonts and Editor Settings
- Changing Font: Navigate to
File > Preferences > Settings(orCode > Preferences > Settings) and search for “Font Family” or “Font Size.” You can specify your preferred font and size for the editor. Popular choices include “Fira Code,” “JetBrains Mono,” and “Consolas.” - Tab Size and Indentation: In the Settings, search for “Tab Size” and “Insert Spaces.” Configure these to match your project’s coding standards.
Essential Extensions
The true power of VS Code lies in its extensive extension marketplace. Extensions can add new languages, debuggers, themes, linters, formatters, and much more.
To install an extension:
- Click the Extensions icon in the Activity Bar (looks like four squares, one of which is detached).
- Search for the extension you want by name or keyword.
- Click the “Install” button for the desired extension.
Here are some highly recommended extensions for general development:
- Prettier – Code formatter: Automatically formats your code to ensure consistency.
- ESLint: Integrates ESLint into VS Code to find and fix problems in your JavaScript code.
- GitLens: Supercharges your Git capabilities within VS Code, offering powerful insights into code authorship and history.
- Docker: Provides rich support for Dockerfiles, docker-compose.yml files, and Dockerfile commands.
- Remote – SSH: Allows you to open any folder on a remote machine using SSH and work with it as if it were local.
- Live Server: Launches a local development server with live reload feature for static and dynamic pages.

Keeping VS Code Updated
If you installed via APT repository:
Your system’s package manager will handle updates. You can update all installed packages, including VS Code, by running:
sudo apt update && sudo apt upgrade
If you installed via .deb package:
You will need to periodically download the latest .deb file from the VS Code website and reinstall it, or repeat the installation steps.
If you installed via Snap:
Snaps update automatically in the background. You can manually check for updates with:
sudo snap refresh code
By following these steps, you can effectively install and configure Visual Studio Code on your Ubuntu system, setting yourself up for productive and efficient software development. The flexibility and extensibility of VS Code, combined with the robust environment of Ubuntu, create a powerful platform for any developer.
