← 返回首页
Installing Visual Studio Code on Linux

Documentation

Topics Overview Overview Linux macOS Windows VS Code for the Web Raspberry Pi Network Additional Components Uninstall VS Code Tutorial Copilot Quickstart User Interface Personalize VS Code Install Extensions Tips and Tricks Intro Videos Overview Setup Quickstart Overview Language Models Context Tools Agents Customization Trust & Safety Overview Agents Tutorial Agents Window Planning Memory Tools Subagents Local Agents Copilot CLI Cloud Agents Third-Party Agents Overview Chat Sessions Add Context Inline Chat Review Edits Checkpoints Artifacts Panel Debug Chat Interactions Prompt Examples Overview Instructions Prompt Files Custom Agents Agent Skills Language Models MCP Hooks Plugins Context Engineering Customize AI Test-Driven Development Edit Notebooks with AI Test with AI Test Web Apps with Browser Tools Debug with AI MCP Dev Guide OpenTelemetry Monitoring Inline Suggestions Smart Actions Best Practices Security Troubleshooting FAQ Cheat Sheet Settings Reference MCP Configuration Workspace Context Display Language Layout Keyboard Shortcuts Settings Settings Sync Extension Marketplace Extension Runtime Security Themes Profiles Overview Voice Interactions Command Line Interface Telemetry Basic Editing IntelliSense Code Navigation Refactoring Snippets Overview Multi-Root Workspaces Workspace Trust Tasks Debugging Debug Configuration Testing Port Forwarding Integrated Browser Overview Quickstart Staging & Committing Branches & Worktrees Repositories & Remotes Merge Conflicts Collaborate on GitHub Troubleshooting FAQ Getting Started Tutorial Terminal Basics Terminal Profiles Shell Integration Appearance Advanced Overview Enterprise Policies AI Settings Extensions Telemetry Updates Overview JavaScript JSON HTML Emmet CSS, SCSS and Less TypeScript Markdown PowerShell C++ Java PHP Python Julia R Ruby Rust Go T-SQL C# .NET Swift Working with JavaScript Node.js Tutorial Node.js Debugging Deploy Node.js Apps Browser Debugging Angular Tutorial React Tutorial Vue Tutorial Debugging Recipes Performance Profiling Extensions Tutorial Transpiling Editing Refactoring Debugging Quick Start Tutorial Run Python Code Editing Linting Formatting Debugging Environments Testing Python Interactive Django Tutorial FastAPI Tutorial Flask Tutorial Create Containers Deploy Python Apps Python in the Web Settings Reference Getting Started Navigate and Edit Refactoring Formatting and Linting Project Management Build Tools Run and Debug Testing Spring Boot Modernizing Java Apps Application Servers Deploy Java Apps GUI Applications Extensions FAQ Intro Videos GCC on Linux GCC on Windows GCC on Windows Subsystem for Linux Clang on macOS Microsoft C++ on Windows Build with CMake CMake Tools on Linux CMake Quick Start C++ Dev Tools for Copilot Editing and Navigating Debugging Configure Debugging Refactoring Settings Reference Configure IntelliSense Configure IntelliSense for Cross-Compiling FAQ Intro Videos Get Started Navigate and Edit IntelliCode Refactoring Formatting and Linting Project Management Build Tools Package Management Run and Debug Testing FAQ Overview Node.js Python ASP.NET Core Debug Docker Compose Registries Deploy to Azure Choose a Dev Environment Customize Develop with Kubernetes Tips and Tricks Overview Jupyter Notebooks Data Science Tutorial Python Interactive Data Wrangler Quick Start Data Wrangler PyTorch Support Azure Machine Learning Manage Jupyter Kernels Jupyter Notebooks on the Web Data Science in Microsoft Fabric Foundry Toolkit Overview Foundry Toolkit Copilot Tools Create Agents Models Playground Agent Builder Agent Inspector Evaluation Tool Catalog Fine-Tuning (Automated Setup) Fine-Tuning (Project Template) Model Conversion Tracing Profiling (Windows ML) FAQ File Structure Manual Model Conversion Manual Model Conversion on GPU Setup Environment Without Foundry Toolkit Template Project Migrating from Visualizer to Agent Inspector Overview Getting Started Resources View Deployment VS Code for the Web - Azure Containers Azure Kubernetes Service Kubernetes MongoDB Remote Debugging for Node.js Overview SSH Dev Containers Windows Subsystem for Linux GitHub Codespaces VS Code Server Tunnels SSH Tutorial WSL Tutorial Tips and Tricks FAQ Overview Tutorial Attach to Container Create Dev Container Advanced Containers devcontainer.json Dev Container CLI Tips and Tricks FAQ Default Keyboard Shortcuts Default Settings Substitution Variables Tasks Schema
Copy as Markdown

On this page there are 7 sections

Installing Visual Studio Code on Linux

Visual Studio Code is available on Linux through official Debian, RPM, and Snap packages. Community-maintained packages are also available for Arch Linux and Nix.

Install VS Code on Linux

Choose the package method that matches your Linux distribution.

Debian and Ubuntu-based distributions
  1. Download the .deb package.

  2. Install the package with the graphical software center, or install it from the command line:

    echo "code code/add-microsoft-repo boolean true" | sudo debconf-set-selections

    To manually install the apt repository:

    1. Install the signing key:

      Types: deb URIs: https://packages.microsoft.com/repos/code Suites: stable Components: main Architectures: amd64,arm64,armhf Signed-By: /usr/share/keyrings/microsoft.gpg
    2. Update the package cache and install the package:

      sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc && echo -e "[code]\nname=Visual Studio Code\nbaseurl=https://packages.microsoft.com/yumrepos/vscode\nenabled=1\nautorefresh=1\ntype=rpm-md\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" | sudo tee /etc/yum.repos.d/vscode.repo > /dev/null
    3. Update the package cache and install the package with dnf on Fedora 22 and later:

      yum check-update && sudo yum install code # or code-insiders
    Note

    Due to the manual signing process and publishing system, the yum repository could lag behind by up to three hours and not immediately contain the latest version of VS Code.

    Snap package

    VS Code is officially distributed as a Snap package in the Snap Store.

    Install the Snap package with this command:

    sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc && echo -e "[code]\nname=Visual Studio Code\nbaseurl=https://packages.microsoft.com/yumrepos/vscode\nenabled=1\nautorefresh=1\ntype=rpm-md\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" | sudo tee /etc/zypp/repos.d/vscode.repo > /dev/null
  3. Update the package cache and install the package:

    nix-env -i vscode
Manual RPM package

Download and install the VS Code .rpm package manually when repository installation is not available. Auto-update does not work unless the repository is installed.

Install the downloaded .rpm package with your package manager, for example with dnf:

xdg-mime default code.desktop text/plain

Debian alternatives system

Debian-based distributions support setting a default editor through the Debian alternatives system, without concern for the MIME type. Set VS Code as the default editor with this command:

sudo update-alternatives --set editor /snap/bin/code

If VS Code doesn't show up as an alternative to the default editor, register it:

# For .deb sudo apt-get update # For .rpm on Fedora 21 and earlier sudo yum check-update # For .rpm on Fedora 22 and later sudo dnf check-update Conflicts with VS Code packages from other repositories

Some distributions, such as Pop!_OS, provide their own code package. To ensure that the official VS Code repository is used, create a file named /etc/apt/preferences.d/code with this content:

sudo apt-get install gvfs libglib2.0-bin "Visual Studio Code is unable to watch for file changes in this large workspace" (error ENOSPC)

This notification indicates that the VS Code file watcher is running out of file handles. This often happens when opening a workspace that contains many files. Before adjusting platform limits, add large folders, such as Python .venv, to the files.watcherExclude Open in VS Code Open in VS Code Insiders setting. Other running applications might also consume file handles, so closing other applications might help.

View the current limit by running:

fs.inotify.max_user_watches=524288

Load the new value:

"files.watcherExclude": { "**/.git/objects/**": true, "**/.git/subtree-cache/**": true, "**/node_modules/*/**": true } I can't see Chinese characters in Ubuntu

Open the application menu, then choose File > Preferences > Settings. In the Text Editor > Font section, set Font Family to Droid Sans Mono, Droid Sans Fallback.

To edit the settings.json file directly, set editor.fontFamily Open in VS Code Open in VS Code Insiders :

# Install sudo apt-get update sudo apt-get install compizconfig-settings-manager # Run ccsm

Under General > General Options > Focus & Raise Behavior, set Focus Prevention Level to Off. This operating system setting applies to all applications, not only VS Code.

Cannot install .deb package due to "/etc/apt/sources.list.d/vscode.list: No such file or directory"

This error can occur when sources.list.d doesn't exist or the current user doesn't have access to create the file. Create the folder and an empty vscode.list file:

E: Repository '...' changed its 'Origin' value from '...' to '...' N: This must be accepted explicitly before updates for this repository can be applied. See apt-secure(8) manpage for details.

Use apt instead of apt-get and accept the origin change when prompted: