How to Install Visual Studio Code on Linux
Installing Visual Studio Code on Linux is easier than you might think. Whether you're a developer, student, or hobbyist, having a powerful code editor like VS Code can boost your productivity. In this guide, I’ll walk you through the simple steps to get Visual Studio Code up and running on your Linux system.
You don’t need to be a Linux expert to follow along. I’ll cover popular Linux distributions like Ubuntu, Fedora, and Debian, and show you how to install VS Code using official repositories and package managers. By the end, you’ll have a smooth setup ready for coding.
Why Choose Visual Studio Code on Linux?
Visual Studio Code (VS Code) is a free, open-source code editor developed by Microsoft. It’s popular because it’s lightweight, fast, and highly customizable. Here’s why you might want to install it on Linux:
- Cross-platform support: Works on Linux, Windows, and macOS.
- Rich extension ecosystem: Thousands of extensions for languages, debuggers, and tools.
- Integrated Git support: Manage your source code directly.
- Built-in terminal: Run commands without leaving the editor.
- Regular updates: Microsoft frequently improves features and security.
If you want a reliable and versatile editor on Linux, VS Code is a top choice.
Preparing Your Linux System for Installation
Before installing VS Code, it’s good to update your system packages. This ensures you have the latest software and security patches.
Open your terminal and run:
sudo apt update && sudo apt upgrade -y
This command works for Debian-based systems like Ubuntu. For Fedora or CentOS, use:
sudo dnf update -y
or
sudo yum update -y
Updating your system helps avoid conflicts during installation.
Installing Visual Studio Code on Ubuntu and Debian
Ubuntu and Debian are among the most popular Linux distributions. Here’s how to install VS Code on them.
Step 1: Import the Microsoft GPG Key
The GPG key verifies the authenticity of the VS Code packages. Run:
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
sudo install -o root -g root -m 644 microsoft.gpg /usr/share/keyrings/
rm microsoft.gpg
Step 2: Add the VS Code Repository
Add the official Microsoft repository to your system sources:
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/microsoft.gpg] https://packages.microsoft.com/repos/code stable main" | sudo tee /etc/apt/sources.list.d/vscode.list
Step 3: Update Package Lists
Refresh your package lists to include the new repository:
sudo apt update
Step 4: Install Visual Studio Code
Now, install VS Code with:
sudo apt install code
Step 5: Launch VS Code
Once installed, you can start VS Code by typing:
code
or find it in your application menu.
Installing Visual Studio Code on Fedora and CentOS
For Fedora and CentOS users, the process is slightly different but still straightforward.
Step 1: Import the Microsoft GPG Key
Run:
sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
Step 2: Add the VS Code Repository
Create a repo file:
sudo sh -c 'echo -e "[code]\nname=Visual Studio Code\nbaseurl=https://packages.microsoft.com/yumrepos/vscode\nenabled=1\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/yum.repos.d/vscode.repo'
Step 3: Update Package Cache
Update your package manager cache:
sudo dnf check-update
Step 4: Install Visual Studio Code
Install VS Code with:
sudo dnf install code
Step 5: Open VS Code
Launch it by typing:
code
or through your desktop environment’s menu.
Alternative Installation Methods
If you prefer not to use repositories, you can install VS Code using Snap or Flatpak, which are universal Linux package managers.
Using Snap
Snap is pre-installed on many Linux distros. To install VS Code via Snap, run:
sudo snap install code --classic
This method is quick and keeps VS Code updated automatically.
Using Flatpak
If you use Flatpak, first ensure it’s installed:
sudo apt install flatpak
Then add the Flathub repository:
flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
Finally, install VS Code:
flatpak install flathub com.visualstudio.code
Launch it with:
flatpak run com.visualstudio.code
Post-Installation Tips for Visual Studio Code on Linux
After installing VS Code, you can enhance your experience with these tips:
- Install Extensions: Use the Extensions view (
Ctrl+Shift+X) to add language support, themes, and tools. - Set Up Git: Configure Git integration by setting your username and email in the terminal.
- Customize Settings: Open settings (
Ctrl+,) to tweak editor behavior and appearance. - Enable Auto Updates: If you installed via Snap or repository, updates happen automatically.
- Use the Integrated Terminal: Press
Ctrl+`to open the terminal inside VS Code.
These steps help you get the most out of your editor.
Troubleshooting Common Installation Issues
Sometimes, you might face problems installing VS Code on Linux. Here are some common issues and fixes:
- GPG Key Errors: Make sure you imported the Microsoft GPG key correctly. Re-run the key import commands.
- Package Not Found: Check if the repository was added properly and your package lists are updated.
- Permission Denied: Use
sudofor commands that require administrative rights. - Snap or Flatpak Not Installed: Install Snap or Flatpak before using those methods.
- Missing Dependencies: Run system updates to ensure all dependencies are met.
If problems persist, check the official VS Code documentation or community forums for help.
How to Uninstall Visual Studio Code on Linux
If you want to remove VS Code, here’s how:
- For Ubuntu/Debian:
sudo apt remove code
sudo apt autoremove
- For Fedora/CentOS:
sudo dnf remove code
- For Snap:
sudo snap remove code
- For Flatpak:
flatpak uninstall com.visualstudio.code
Uninstalling is straightforward and cleans up your system.
Conclusion
Installing Visual Studio Code on Linux is a smooth process whether you use Ubuntu, Fedora, or other distributions. By adding the official Microsoft repository or using Snap/Flatpak, you can quickly get the latest version of VS Code. This editor offers powerful features that help you code efficiently.
Once installed, take advantage of extensions and customization to tailor VS Code to your needs. If you run into issues, the Linux community and official docs provide plenty of support. Now you’re ready to start coding with one of the best editors available on Linux.
FAQs
How do I update Visual Studio Code on Linux?
If installed via repository or Snap, VS Code updates automatically with system updates. You can manually update with sudo apt update && sudo apt upgrade or sudo snap refresh code.
Can I install Visual Studio Code without internet?
You can download the .deb or .rpm package on another machine and transfer it via USB. Then install using sudo dpkg -i package.deb or sudo rpm -i package.rpm.
Is Visual Studio Code free on Linux?
Yes, Visual Studio Code is free and open-source. You can download and use it without any cost on Linux.
What are the system requirements for VS Code on Linux?
VS Code runs on most modern Linux distributions with at least 1 GB RAM and 200 MB disk space. It supports 64-bit architectures.
Can I use VS Code for Python development on Linux?
Absolutely. VS Code supports Python with extensions that provide linting, debugging, and IntelliSense features, making it ideal for Python developers on Linux.
